Regex Unicode
Match emoji, CJK, and scripts correctly with unicode mode.
- unicode regex
- match emoji
- CJK regex
- unicode property
- astral char
Regex Unicode
Match emoji, CJK, and scripts correctly with unicode mode.
Commands
| Command | What it does |
|---|---|
/\p{L}/u | Any letter, any script |
/\p{Script=Han}/u | Han characters |
/\p{Emoji}/u | Emoji codepoints |
/\u{1F600}/u | One astral char by codepoint |
/^[\p{L}\p{N}_.-]+$/u | Unicode-safe username |
Example
/\p{Script=Han}+/gu.test('cheatsheet')
FAQ
Why does an emoji have length 2?
Astral chars are UTF-16 surrogate pairs; spread into an array for real counts.
When is backslash-w wrong?
It is ASCII-only; use unicode letter and number properties for international identifiers.
الأسئلة الشائعة
Why does an emoji have length 2?
Astral chars are UTF-16 surrogate pairs; spread into an array for real counts.
When is backslash-w wrong?
It is ASCII-only; use unicode letter and number properties for international identifiers.