RegExp.prototype.multiline

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.

概述

multiline 属性表明正则表达式是否使用了 "m" 标志。multiline 是正则表达式实例的一个只读属性。

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

描述

multiline 是一个布尔对象,如果使用了 "m" 标志,则返回 true;否则,返回 false。"m" 标志意味着一个多行输入字符串被看作多行。例如,使用 "m","^" 和 "$" 将会从只匹配正则字符串的开头或结尾,变为匹配字符串中任一行的开头或结尾。

你无法直接更改此属性。

示例

示例:使用 multiline

js
var regex = new RegExp("foo", "m");

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

规范

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

浏览器兼容性

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
multiline
Prototype accessor property (ES2015)

Legend

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

Full support
Full support

参见