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.73k stars 174 forks source link

🎖 is not matched #32

Closed brekk closed 6 years ago

brekk commented 6 years ago

Hey there,

Love this library, but I've been seeing some new(er) emojis that are not matched correctly?

import emojiRegex from 'emoji-regex'
const e = emojiRegex()
e.test('🎖') // false

Thanks,

Brekk

astoilkov commented 6 years ago

I can add 🗡 to this issue.

gilmoreorless commented 6 years ago

Both of those are defined in the Emoji category but not the Emoji_Presentation category in the Unicode source data. Technically they're meant to have different representations for "plain text" vs "emoji" modes, based on the presence or absence of the presentation selector U+FE0F. Unfortunately OSes are notoriously sloppy with adhering to that (see #28 (comment)), and the default regex is not matching the "plain text" variant.

Those characters are matched by the text version of emoji-regex, which ignores the presentation selector:

const emojiRegex = require('emoji-regex')
emojiRegex().test('🎖')  // false

const emojiTextRegex = require('emoji-regex/text')
emojiTextRegex().test('🎖')  // true