const emojiRegex = require('emoji-regex');
const text = `
🦰
🏻
`;
const regex = emojiRegex();
for (const match of text.matchAll(regex)) {
const emoji = match[0];
console.log(`Matched sequence ${ emoji } — code points: ${ [...emoji].length }`);
}
Output:
Matched sequence 🦰 — code points: 1
Matched sequence 🏻 — code points: 1
Technically, I don't think these are Emoji. Maybe we should add an option to exclude these.
https://www.unicode.org/Public/emoji/16.0/emoji-test.txt
# All omitted code points have Emoji_Component=No
0023 ; Emoji_Component # E0.0 [1] (#️) hash sign
002A ; Emoji_Component # E0.0 [1] (*️) asterisk
0030..0039 ; Emoji_Component # E0.0 [10] (0️..9️) digit zero..digit nine
200D ; Emoji_Component # E0.0 [1] () zero width joiner
20E3 ; Emoji_Component # E0.0 [1] (⃣) combining enclosing keycap
FE0F ; Emoji_Component # E0.0 [1] () VARIATION SELECTOR-16
1F1E6..1F1FF ; Emoji_Component # E0.0 [26] (🇦..🇿) regional indicator symbol letter a..regional indicator symbol letter z
1F3FB..1F3FF ; Emoji_Component # E1.0 [5] (🏻..🏿) light skin tone..dark skin tone
1F9B0..1F9B3 ; Emoji_Component # E11.0 [4] (🦰..🦳) red hair..white hair
E0020..E007F ; Emoji_Component # E0.0 [96] (..) tag space..cancel tag
Output:
Technically, I don't think these are Emoji. Maybe we should add an option to exclude these.
https://www.unicode.org/Public/emoji/16.0/emoji-test.txt