RegExp /u Flag
Examples
const text = "䷀";
const pattern = /\u{04DC0}/u;
let result = pattern.test(text);
Try it Yourself »
const text = "䷀";
const pattern = /\u{04DC0}/;
let result = pattern.test(text);
Try it Yourself »
Description
The /u (unicode) flag enables full Unicode support in the regular expression.
By default, JavaScript RegExp treats 4-byte Unicode characters (like emojis or less common symbols) as two separate 2-byte "surrogate" code units.
The /u flag treats the pattern as a sequence of Unicode code points, which is important for correctly handling of characters outside the Basic Multilingual Plane (BMP).
Note
JavaScript 2025 introduced the /v flag as an "upgrade" to the /u flag.
The /v Flag (unicodeSets) enables more Unicode-related features.
Syntax
new RegExp("regexp", "u")
or simply:
/regexp/u
See Also:
The Corresponding Property: unicode
Regular Expression Search Methods
In JavaScript, a regular expression text search, can be done with different methods.
With a pattern as a regular expression, these are the most common methods:
String Methods
match(pattern) | An Array of results |
matchAll(pattern) | An Iterator of results |
replace(pattern, rep) | A new String |
search(pattern) | Index of the first match |
split(pattern) | An Array of results |
RegExp Methods
pattern.exec() | An Iterator of results |
pattern.test() | true or false |
Browser Support
/regexp/u
is an ECMAScript6 (ES6 2015) feature.
JavaScript 2015 is supported in all browsers since June 2017:
Chrome 51 | Edge 15 | Firefox 54 | Safari 10 | Opera 38 |
May 2016 | Apr 2017 | Jun 2017 | Sep 2016 | Jun 2016 |