This is my first question on Stack Overflow, I would love help.
I use a regex to detect emojis from a user inputed text. The regex I am using to match emojis is:
(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])
However, on mobile only, it is also matching various non-emoji symbols including '
and "
I've tried other regex's for emoji matches, but none have been as concise as this one or work as well.
Can anyone help me out?
To see the problem live, insert text/emojis/symbols into the Personal Message field (using mobile device): https://2050.cards/shop/birthday/eskimo-surprise/
Example input:
Should not and does not match:
Dear you, Happy Birthday.
Should match and does match:
Dear you 😎, Thanks. 😊
Should not BUT DOES match (on mobile only):
Dear you, let's all "hang out"
The correct way to do this, is with Unicode property escapes.
const r = /\p{Emoji}/u;
const a = [
'Dear you 😎, Thanks. 😊',
'Dear you, Happy Birthday.',
`Dear you, let's all "hang out" • spend some €`
];
for (const s of a) {
const b = r.test(s);
console.log(b);
}
This is supported with: