mathiasbynens / emoji-regex

A regular expression to match all Emoji-only symbols as per the Unicode Standard.
https://mths.be/emoji-regex
MIT License
1.74k stars 174 forks source link

Some Apple emoji do not match #2

Closed flipactual closed 9 years ago

flipactual commented 9 years ago

:relaxed:, :one:, and :heart: for example.

I'm sure there's a reason for this, but my app needs them to match.

Would you consider an optional parameter that would also match these characters? Maybe something like:

emojiRegex({includeNotTechnicallyEmojiCharacters: true});

I'd be happy to put the PR in, just wanted to check if this is a desirable feature.

luin commented 9 years ago

+1

mathiasbynens commented 9 years ago

I'm sure there's a reason for this […]

For the record, the reason is this one (emphasis added):

unicode-tr51 contains data extracted from the emoji-data.txt file that is part of Unicode Technical Report #51. _Specifically, the data lists all emoji symbols that lack a text equivalent._

1️⃣ is '1\uFE0F\u20E3', i.e. 1 followed by a variation selector, followed by COMBINING ENCLOSING KEYCAP. Since U+0031 U+20E3 appears in the emoji data text file, this would match after stripping variation selectors from the input, if unicode-tr51 didn’t specifically exclude emoji that have a textual representation by default. Perhaps that should change, though.

mathiasbynens commented 9 years ago

Changed both projects to include text emoji as well. @flipactual You’ll want to use https://github.com/mathiasbynens/strip-variation-selectors on the input before running emoji-regex on it.