In JavaScript, regex.unicode is a read-only boolean. It is true when the RegExp was created with the u flag.
With u, the engine treats the pattern as Unicode code points. That matters for emoji and other characters outside the basic multilingual plane, and it enables escapes like \u{1F600}.
Syntax
Create the regex with u, then read .unicode.
JavaScript
const a = /./;
const b = /./u;
const c = new RegExp(".", "u");
console.log(a.unicode); // false
console.log(b.unicode); // true
console.log(c.unicode); // true
Call
What it does
/./u
Unicode mode. unicode is true.
/\u{1F600}/u
Match an emoji by code point escape.
new RegExp(".", "u")
Same as the literal with u.
Remember this at a glance:
Remember
/./.unicode → false
/./u.unicode → true
with u:
. matches one code point (not half a surrogate pair)
\u{1F600} emoji escapes work
flags are fixed at creation
What You Get
Name
Description
regex.unicode
Read-only. true if the u flag was set when the RegExp was created.
u flag
Set at creation with /…/u or new RegExp(pattern, "u").
Code points
With u, patterns and . work on full Unicode characters.
Return Value
Value
Description
true
The RegExp has the u (unicode) flag.
false
The RegExp does not have the u flag.
JavaScript Examples
Example 1 — Read unicode
See how the u flag sets the property.
JavaScript
const a = /a/;
const b = /a/u;
const c = new RegExp("a", "u");
console.log(a.unicode);
console.log(b.unicode);
console.log(c.unicode);
console.log(c.flags);