The unicode
accessor property indicates whether or not the u
flag is used with the regular expression.
The unicode
accessor property indicates whether or not the u
flag is used with the regular expression.
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:
\u{xxxx}
, \p{UnicodePropertyValue}
) will be interpreted as such instead of as literal characters./[😄]/u
would only match "😄"
but not "\ud83d"
.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.
const regex = /\u{61}/u; console.log(regex.unicode); // true
Desktop | Mobile | Server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | Deno | Node.js | |
unicode |
50 |
12
Case folding is implemented in version 13
|
46 |
No |
37 |
10 |
50 |
50 |
46 |
37 |
10 |
5.0 |
1.0 |
6.0.0
Case folding is implemented in version 8.6.0
|
© 2005–2022 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/unicode