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/dotAll below:

RegExp.prototype.dotAll - JavaScript | MDN

RegExp.prototype.dotAll

Baseline Widely available

dotAll は RegExp インスタンスのアクセサープロパティで、正規表現で s フラグが使用されているかどうかを示します。

試してみましょう
const regex1 = new RegExp("foo", "s");

console.log(regex1.dotAll);
// Expected output: true

const regex2 = new RegExp("bar");

console.log(regex2.dotAll);
// Expected output: false
解説

RegExp.prototype.dotAll の値は s フラグが使用されている場合は true、それ以外の場合は false です。s フラグは、ドット特殊文字 (.) が追加で行末記号 ("newline") 文字と一致することを示します。これ以外の場合は一致しません。

これは事実上、ドットが基本多言語面 (BMP) のすべての文字と一致することを意味します。アストラル文字と一致させるには、u (Unicode) フラグを使用する必要があります。両方のフラグを組み合わせて使用すると、ドットは例外なく任意の Unicode 文字に一致します。

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

例 dotAll の使用
const str1 = "bar\nexample foo example";

const regex1 = /bar.example/s;

console.log(regex1.dotAll); // true

console.log(str1.replace(regex1, "")); // foo example

const str2 = "bar\nexample foo example";

const regex2 = /bar.example/;

console.log(regex2.dotAll); // false

console.log(str2.replace(regex2, ""));
// bar
// example foo example
仕様書 ブラウザーの互換性 関連情報

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