RegExp.prototype.unicodeSets

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2023.

The unicodeSets accessor property of RegExp instances returns whether or not the v flag is used with this regular expression.

Try it

const regex1 = /[\p{Lowercase}&&\p{Script=Greek}]/;
const regex2 = /[\p{Lowercase}&&\p{Script=Greek}]/v;

console.log(regex1.unicodeSets);
// Expected output: false

console.log(regex2.unicodeSets);
// Expected output: true

Description

RegExp.prototype.unicodeSets has the value true if the v flag was used; otherwise, false. The v flag is an "upgrade" to the u flag that enables more Unicode-related features. ("v" is the next letter after "u" in the alphabet.) Because u and v interpret the same regex in incompatible ways, using both flags results in a SyntaxError. With the v flag, you get all features mentioned in the u flag description, plus:

  • The \p escape sequence can be additionally used to match properties of strings, instead of just characters.
  • The character 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, see Complement classes and case-insensitive matching.

Some valid u-mode regexes become invalid in v-mode. Specifically, the character class syntax is different and some characters can no longer appear literally. For more information, see v-mode character class.

Note: The v 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 of unicodeSets is undefined. You cannot change this property directly.

Examples

Using the unicodeSets property

js
const regex = /[\p{Script_Extensions=Greek}&&\p{Letter}]/v;

console.log(regex.unicodeSets); // true

Specifications

Specification
ECMAScript® 2027 Language Specification
# sec-get-regexp.prototype.unicodesets

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
Node.js
unicodeSets
Chrome – Full support
Chrome 112 (Release date: 2023-04-04)
footnote Full support
Edge – Full support
Edge 112 (Release date: 2023-04-06)
footnote Full support
Firefox – Full support
Firefox 116 (Release date: 2023-08-01)
footnote Full support
Opera – Full support
Opera 98 (Release date: 2023-04-20)
footnote Full support
Safari – Full support
Safari 17 (Release date: 2023-09-18)
footnote Full support
Chrome Android – Full support
Chrome Android 112 (Release date: 2023-04-04)
footnote Full support
Firefox for Android – Full support
Firefox for Android 116 (Release date: 2023-08-01)
footnote Full support
Opera Android – Full support
Opera Android 75 (Release date: 2023-05-17)
footnote Full support
Safari on iOS – Full support
Safari on iOS 17 (Release date: 2023-09-18)
footnote Full support
Samsung Internet – Full support
Samsung Internet 23 (Release date: 2023-10-18)
footnote Full support
WebView Android – Full support
WebView Android 112 (Release date: 2023-04-04)
footnote Full support
WebView on iOS – Full support
WebView on iOS 17 (Release date: 2023-09-18)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1.32 (Release date: 2023-03-23)
footnote Full support
Node.js – Full support
Node.js 20 (Release date: 2023-04-18)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also