Spec-Zone.ru › JavaScript

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 July 2015.

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

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
112
112
116
98
17
112
116
75
17
23.0
112
17
1.0.0
1.32
20.0.0

See also

  • RegExp.prototype.lastIndex
  • RegExp.prototype.dotAll
  • RegExp.prototype.global
  • RegExp.prototype.hasIndices
  • RegExp.prototype.ignoreCase
  • RegExp.prototype.multiline
  • RegExp.prototype.source
  • RegExp.prototype.sticky
  • RegExp.prototype.unicode
  • RegExp v flag with set notation and properties of strings on v8.dev (2022)

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicodeSets

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API