JavaScript / ECMAScript

Emoji (Unicode) in JS

Match emoji characters across the main Unicode emoji ranges — requires the Unicode flag in JavaScript.

Try it in the JS tester →

Pattern

regexJS
[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{FE00}-\u{FEFF}\u{1F000}-\u{1F02F}\u{1FA00}-\u{1FA9F}]   (flags: gu)

JavaScript / ECMAScript code

jsJavaScript
const re = new RegExp("[\\u{1F300}-\\u{1F9FF}\\u{2600}-\\u{26FF}\\u{2700}-\\u{27BF}\\u{FE00}-\\u{FEFF}\\u{1F000}-\\u{1F02F}\\u{1FA00}-\\u{1FA9F}]", "gu");
const input = "Hello 🌍 World 🎉";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));

Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).

How the pattern works

The character class covers the primary emoji Unicode blocks: Miscellaneous Symbols and Pictographs (1F300–1F9FF), Misc Symbols (2600–26FF), Dingbats (2700–27BF), Variation Selectors (FE00–FEFF), Mahjong/playing cards (1F000–1F02F), and Supplemental Symbols (1FA00–1FA9F). The u flag in JavaScript is required to interpret \u{XXXXX} code points above 0xFFFF. In Python, use re.UNICODE (default in Python 3). In Go RE2, use \x{XXXXX} syntax instead of \u{XXXXX}.

Examples

Input

Hello 🌍 World 🎉

Matches

  • 🌍
  • 🎉

Input

⚡ Fast ☁ Cloud ⭐ Star

Matches

Input

plain text only

No match

Same pattern, other engines

← Back to Emoji (Unicode) overview (all engines)