A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/RegExp/multiline below:

RegExp.prototype.multiline - JavaScript | MDN

RegExp.prototype.multiline

Baseline Widely available

multiline は RegExp のアクセサープロパティで、正規表現で m フラグが使用されているかどうかを返します。

試してみましょう
const regex1 = new RegExp("^football");
const regex2 = new RegExp("^football", "m");

console.log(regex1.multiline);
// Expected output: false

console.log(regex2.multiline);
// Expected output: true

console.log(regex1.test("rugby\nfootball"));
// Expected output: false

console.log(regex2.test("rugby\nfootball"));
// Expected output: true
解説

RegExp.prototype.multiline の値は m フラグが使われていたならば true となり、そうでなければ false になります。m フラグは複数行の入力文字列が複数行として扱われるべきであることを示します。例えば、m フラグが使われた場合、^ と $ は文字列の全体の先頭と末尾だけに一致する特殊文字から、文字列内のそれぞれの行の先頭と末尾に一致する特殊文字に変化します。

multiline の設定アクセサーは undefined です。このプロパティを直接変更することはできません。

例 multiline の使用
const regex = /foo/m;

console.log(regex.multiline); // true
仕様書 ブラウザーの互換性 関連情報

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4