u - Unicode Flag
RX · Flags & Modifierssyntax
JS: /pattern/u Python: (Unicode by default in Python 3)example
JS: /^.$/u.test('[U+D83D][U+DE00]') // true (emoji as one char)
JS: /^.$/.test('[U+D83D][U+DE00]') // false (two UTF-16 surrogates)
JS: /\p{Emoji}/u.test('Hi') // true (enables \p{} syntax)output
With u: emoji treated as single character
Without u: emoji seen as two surrogate code unitsNote In JS, the u flag enables full Unicode matching: surrogate pairs are treated as single code points, and Unicode property escapes (\p{...}) become available. Python 3 handles Unicode by default. Always use the u flag in JS when dealing with international text or emoji.