RegExp.prototype.unicodeSets
Baseline 2023Newly available
Since September 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
TheunicodeSets accessor property ofRegExp instances returns whether or not thev flag is used with this regular expression.
In this article
Try it
const regex1 = /[\p{Lowercase}&&\p{Script=Greek}]/;const regex2 = /[\p{Lowercase}&&\p{Script=Greek}]/v;console.log(regex1.unicodeSets);// Expected output: falseconsole.log(regex2.unicodeSets);// Expected output: trueDescription
RegExp.prototype.unicodeSets has the valuetrue if thev flag was used; otherwise,false. Thev flag is an "upgrade" to theu flag that enables more Unicode-related features. ("v" is the next letter after "u" in the alphabet.) Becauseu andv interpret the same regex in incompatible ways, using both flags results in aSyntaxError. With thev flag, you get all features mentioned in theu flag description, plus:
- The
\pescape sequence can be additionally used to match properties of strings, instead of just characters. - Thecharacter class syntax is upgraded to allow intersection, union, and subtraction syntaxes, as well as matching multiple Unicode characters.
- The character class complement syntax
[^...]constructs a complement class instead of negating the match result, avoiding some confusing behaviors with case-insensitive matching. For more information, seeComplement classes and case-insensitive matching.
Some validu-mode regexes become invalid inv-mode. Specifically, the character class syntax is different and some characters can no longer appear literally. For more information, seev-mode character class.
Note:Thev mode does not interpret grapheme clusters as single characters; they are still multiple code points. For example,/[🇺🇳]/v is still able to match"🇺".
The set accessor ofunicodeSets isundefined. You cannot change this property directly.
Examples
>Using the unicodeSets property
const regex = /[\p{Script_Extensions=Greek}&&\p{Letter}]/v;console.log(regex.unicodeSets); // trueSpecifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-get-regexp.prototype.unicodesets> |