Emoji Regex
Matches a single emoji character using the Unicode Extended_Pictographic property, which requires the u (or v) flag for Unicode property escapes.
Regex Pattern
\p{Extended_Pictographic}Default flags: u
Pattern Breakdown
Hover over a token to see what it does.
| Token | Meaning |
|---|---|
| \p | Introduces a Unicode property escape; only valid when the regex has the u or v flag |
| { | Opens the property name that \p should test each character against |
| Extended_Pictographic | The specific Unicode binary property matched: true for characters designed to be rendered as pictographs/emoji, excluding standalone digits and punctuation |
| } | Closes the property name |
Detailed Explanation
What it does
This pattern matches any single character in Unicode's Extended_Pictographic category, which covers emoji characters like ๐, ๐, and โค regardless of whether they're presented with color or as text. It intentionally uses Extended_Pictographic rather than the broader \p{Emoji} property.
Why it works
JavaScript's \p{...} Unicode property escapes only work when the u (or newer v) flag is present, because without it the engine treats \p as an unrecognized escape and the braces as literal characters. Extended_Pictographic is preferred over the plain Emoji property because Emoji also includes 'Emoji_Component' characters like plain digits 0-9, the # and * keys, and skin tone modifiers, which are only emoji when combined with other characters (e.g. keycap sequences) โ matching them standalone would produce false positives on ordinary digits and punctuation.
Common use cases
- Detecting whether a piece of user-generated text contains emoji, for moderation or analytics
- Stripping or replacing emoji from text before passing it to systems that don't support them
- Counting emoji usage in chat messages or social media posts
- Splitting text into emoji and non-emoji segments for custom rendering
Edge cases
- Multi-codepoint emoji built from ZWJ sequences (e.g. a family emoji made of several people joined by zero-width joiners) will match on each individual pictographic component, not as one atomic unit, unless combined with \p{Emoji_Presentation} and ZWJ-aware grouping
- Variation selectors (U+FE0F) that force emoji-style rendering of an otherwise text-style character are not matched themselves, only the base character is
- Plain digits and # are correctly NOT matched by Extended_Pictographic even though they are matched by the broader \p{Emoji} property, since they're only Emoji_Component characters
- Some symbol characters with long-standing pictographic use, like โ or โ, are included in Extended_Pictographic even though they predate modern emoji
- Regional indicator letters used to build flag emoji are not covered by Extended_Pictographic and would need \p{Regional_Indicator} matched separately
Limitations
- Requires the u or v flag; omitting it causes \p{...} to be parsed as a literal, non-functional sequence in JavaScript
- Does not treat multi-codepoint emoji sequences (skin tones, ZWJ sequences, flags) as single matched units without additional pattern work
- Support for Unicode property escapes varies significantly by language and regex engine version, so equivalent patterns differ across ecosystems
- The exact set of characters considered 'emoji' can shift slightly between Unicode versions as new pictographs are added
Interactive Tester
Edit the pattern or text below โ matching runs live in your browser.
Test Cases
Editable โ add your own inputs to see if they pass.
| Input | Expected | Result | |
|---|---|---|---|
| Pass | |||
| Pass | |||
| Pass | |||
| Pass | |||
| Pass | |||
| Pass | |||
| Pass | |||
| Pass |
Language Variants
Production-ready examples in 12 languages.
const emojiRegex = /\p{Extended_Pictographic}/u;
console.log(emojiRegex.test('Great job! ๐')); // trueCommon Mistakes
Using \p{Emoji} instead of \p{Extended_Pictographic}, which unexpectedly matches plain digits, #, and * because they're classified as Emoji_Component characters
Fix: Use \p{Extended_Pictographic} when the intent is 'does this look like a pictograph', reserving \p{Emoji} for contexts that intentionally include keycap components
Forgetting the u flag in JavaScript, which throws a SyntaxError or silently fails to interpret \p{...} as a Unicode property escape
Fix: Always pair \p{...} escapes with the u (or v) flag in JavaScript
Assuming a multi-part emoji like a ZWJ family sequence or flag will match as one unit with this single-character pattern
Fix: Use grapheme-cluster-aware iteration (e.g. Intl.Segmenter in JS) instead of a single character class match when whole emoji sequences need to be treated atomically
Performance Notes
- Unicode property lookups like \p{Extended_Pictographic} are implemented as compact range tables internally, so matching is fast despite covering thousands of code points
- Without the g flag, .test() only checks for the first occurrence and stops, which is sufficient for a boolean 'contains emoji' check
- For extracting all emoji from long text, combine with the g flag but be aware that surrogate-pair and ZWJ sequences may need additional grouping logic for accurate counts
Browser Compatibility
| Engine | Supported | Notes |
|---|---|---|
| Chrome | Yes | Requires the u or v flag for \p{} Unicode property escapes; supported since Chrome 64 |
| Firefox | Yes | Requires the u or v flag; supported since Firefox 78 |
| Safari | Yes | Requires the u or v flag; supported since Safari 11.1 |
| Edge | Yes | Requires the u or v flag; supported since Edge 79 (Chromium-based) |
| Node.js | Yes | Requires the u or v flag; supported since Node.js 10 |