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.72k stars 175 forks source link

Switch to a much more simple emoji regex, also add other universal exports #103

Closed fritx closed 1 year ago

fritx commented 1 year ago

This much simple emoji regex is modified from:

How to detect emoji using javascript https://stackoverflow.com/questions/18862256/how-to-detect-emoji-using-javascript

And is being used here in silent

All tests can pass with this regex

image
mathiasbynens commented 1 year ago

How is this "simpler"? You're replacing a carefully-at-build-time-generated regular expression pattern that can easily be updated to newer Unicode/Emoji standards with a hardcoded pattern that offers little explanation as to how or why it works.

From looking at the pattern, it seems to match not only RGI_Emoji (hence it passing all the tests) but also emoji sequences that are not yet standardized nor supported anywhere. If this is what you want, then emoji-regex is not the package for you. OTOH, if you want to match exactly all emoji per the latest Unicode standard and nothing else, then stick to emoji-regex.

fritx commented 1 year ago

Thanks so much for your explanation.

Sorry about missing those important contexts of this library.

It is standard oriented while the simpler one is a loose and hacky version.

mathiasbynens commented 1 year ago

No worries. I could imagine use cases for either approach. In the future we'll be able to use /\p{RGI_Emoji}/v :)