The unicode accessor property indicates whether or not the u flag is used with the regular expression.

Try it


RegExp.prototype.unicode has the value true if the u flag was used; otherwise, false. The u flag enables various Unicode-related features. With the "u" flag:

  • Any Unicode code point escapes (\u{xxxx}, \p{UnicodePropertyValue}) will be interpreted as such instead of as literal characters.
  • Surrogate pairs will be interpreted as whole characters instead of two separate characters. For example, /[😄]/u would only match "😄" but not "\ud83d".
  • When lastIndex is automatically advanced (such as when calling exec()), unicode regexes advance by Unicode code points instead of UTF-16 code units.

There are other changes to the parsing behavior that prevent possible syntax mistakes (which are analogous to strict mode for regex syntax). This is explained in more detail in Using Unicode regular expressions.

The set accessor of unicode is undefined. You cannot change this property directly.


Using the unicode property

const regex = /\u{61}/u;

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


ECMAScript Language Specification
# sec-get-regexp.prototype.unicode

Browser compatibility

BCD tables only load in the browser

See also