RegExp.prototype.unicode

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.

unicode 属性表明正则表达式带有"u" 标志。 unicode 是正则表达式独立实例的只读属性。

RegExp.prototype.unicode 的属性特性
可写
可枚举
可配置

描述

unicode 的值是 Boolean,并且如果使用了 "u" 标志则为 true;否则为 false。"u" 标志开启了多种 Unicode 相关的特性。使用 "u" 标志,任何 Unicode 代码点的转义都会被解释。

你不能直接修改这个属性,它是只读的。

示例

使用 unicode 属性

js
var regex = new RegExp("\u{61}", "u");

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

规范

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

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
unicode

Legend

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

Full support
Full support
See implementation notes.

参见