RegExp.prototype.multiline
BaselineWidely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Themultiline
accessor property ofRegExp
instances returns whether or not them
flag is used with this regular expression.
Try it
const regex1 = /^football/;const regex2 = /^football/m;console.log(regex1.multiline);// Expected output: falseconsole.log(regex2.multiline);// Expected output: trueconsole.log(regex1.test("rugby\nfootball"));// Expected output: falseconsole.log(regex2.test("rugby\nfootball"));// Expected output: true
Description
RegExp.prototype.multiline
has the valuetrue
if them
flag was used; otherwise,false
. Them
flag indicates that a multiline input string should be treated as multiple lines. For example, ifm
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.
The set accessor ofmultiline
isundefined
. You cannot change this property directly.
Examples
Using multiline
js
const regex = /^foo/m;console.log(regex.multiline); // true
Specifications
Specification |
---|
ECMAScript® 2026 Language Specification # sec-get-regexp.prototype.multiline |