Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

RegExp.prototype.multiline

BaselineWidely available

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

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp