JavaScript RegExp unicodeSets Property

Beginner
5 min read
Updated: Nov 2026
3 examples
RegExp

Definition

In JavaScript, regex.unicodeSets is a read-only boolean. It is true when the RegExp was created with the v flag.

The v flag is a newer Unicode mode. It improves character classes (sets) and implies Unicode matching. Prefer v when you need set syntax; otherwise u is enough for most Unicode work.

Syntax

Create the regex with v, then read .unicodeSets.

JavaScript
const a = /a/;
const b = /a/v;
const c = new RegExp("a", "v");

console.log(a.unicodeSets); // false
console.log(b.unicodeSets); // true
console.log(c.unicodeSets); // true
CallWhat it does
/a/vUnicode sets mode. unicodeSets is true.
/[\p{Number}]/vExample of a property escape in v mode (when supported).
new RegExp("a", "v")Same as the literal with v.

Remember this at a glance:

Remember
 /a/.unicodeSets      → false
 /a/v.unicodeSets     → true

v → Unicode sets mode (includes Unicode behavior)
u → classic Unicode mode

you cannot use u and v together on one regex

What You Get

NameDescription
regex.unicodeSetsRead-only. true if the v flag was set when the RegExp was created.
v flagSet at creation with /…/v or new RegExp(pattern, "v").
vs uv replaces u for set-focused Unicode features. Do not combine u and v.

Return Value

ValueDescription
trueThe RegExp has the v (unicodeSets) flag.
falseThe RegExp does not have the v flag.

JavaScript Examples

Example 1 — Read unicodeSets

See how the v flag sets the property.

JavaScript
const a = /x/;
const b = /x/v;
const c = new RegExp("x", "v");

console.log(a.unicodeSets);
console.log(b.unicodeSets);
console.log(c.unicodeSets);
console.log(c.flags);
Try It Yourself

How It Works

  1. Without v, unicodeSets is false.
  2. With /x/v, unicodeSets is true.
  3. The constructor with "v" does the same.
  4. flags reports "v".

Example 2 — Compare u and v

Both enable Unicode-aware matching; only one flag at a time.

JavaScript
const withU = /./u;
const withV = /./v;

console.log(withU.unicode);
console.log(withU.unicodeSets);
console.log(withV.unicode);
console.log(withV.unicodeSets);
Try It Yourself

How It Works

  1. The u flag sets unicode only.
  2. The v flag sets unicodeSets, and Unicode matching is also on.
  3. Pick u or v, not both.

Example 3 — Simple match with v

A short check that v patterns still match normally.

JavaScript
const re = /cat/iv;

console.log(re.test("CAT"));
console.log(re.unicodeSets);
console.log(re.ignoreCase);
Try It Yourself

How It Works

  1. i ignores letter case.
  2. v turns on unicodeSets.
  3. Ordinary literal text still matches as you expect.

Frequently Asked Questions

It is true when the regex was created with the v flag. That enables Unicode sets mode for character classes.
Use u for classic Unicode mode. Use v when you need the newer set features. Do not set both on one RegExp.
Support is newer than u. If /pattern/v throws a syntax error, fall back to u for basic Unicode matching.
No. Create a new RegExp with the v flag.
No. hasIndices is the d flag for match indices. unicodeSets is the v flag for Unicode sets.
Learn u first for emoji and code points. Add v later if you need set syntax.

Next: hasIndices

Get start and end indexes for each match with the d flag.

hasIndices tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful