RegExp.prototype.multiline

RegExp 实例的 multiline 访问器属性返回此正则表达式是否使用 m 标志。

¥The multiline accessor property of RegExp instances returns whether or not the m flag is used with this regular expression.

Try it

描述

¥Description

如果使用了 m 标志,则 RegExp.prototype.multiline 的值为 true;否则,falsem 标志指示多行输入字符串应被视为多行。例如,如果使用 m,则 ^$ 从仅匹配整个字符串的开头或结尾更改为匹配字符串内任何行的开头或结尾。

¥RegExp.prototype.multiline has the value true if the m flag was used; otherwise, false. The m flag indicates that a multiline input string should be treated as multiple lines. For example, if m is used, ^ and $ change from matching at only the start or end of the entire string to the start or end of any line within the string.

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

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

示例

¥Examples

使用多行

¥Using multiline

js
const regex = /foo/m;

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

规范

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

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看