RegExp.prototype.flags

RegExp 实例的 flags 访问器属性返回此正则表达式的 flags

¥The flags accessor property of RegExp instances returns the flags of this regular expression.

Try it

描述

¥Description

RegExp.prototype.flags 有一个字符串作为其值。flags 属性中的标志按字母顺序排序(从左到右,例如 "dgimsuvy")。它实际上一一调用其他标志访问器(hasIndicesglobal 等)并连接结果。

¥RegExp.prototype.flags has a string as its value. Flags in the flags property are sorted alphabetically (from left to right, e.g. "dgimsuvy"). It actually invokes the other flag accessors (hasIndices, global, etc.) one-by-one and concatenates the results.

所有内置函数都会读取 flags 属性,而不是读取各个标志访问器。

¥All built-in functions read the flags property instead of reading individual flag accessors.

flags 的集合访问器是 undefined。你不能直接更改此属性。

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

示例

¥Examples

使用标志

¥Using flags

js
/foo/ig.flags; // "gi"
/bar/myu.flags; // "muy"

规范

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

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看