Es6-regexp-prototype-ignorecase

提供:Dev Guides
2020年6月23日 (火) 08:04時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

ES6-RegExp ignoreCase

ignoreCaseは、RegExpオブジェクトの読み取り専用のブール型プロパティです。 特定の正規表現が大文字と小文字を区別しないマッチングを実行するかどうか、つまり「i」属性で作成されたかどうかを指定します。

構文

RegExpObject.ignoreCase

戻り値

「i」修飾子が設定されている場合は「TRUE」、それ以外の場合は「FALSE」を返します。

var re = new RegExp( "string" );

if ( re.ignoreCase ){
   console.log("Test1-ignoreCase property is set");
} else {
   console.log("Test1-ignoreCase property is not set");
}
re = new RegExp( "string", "i" );

if ( re.ignoreCase ) {
   console.log("Test2-ignoreCase property is set");
} else {
   console.log("Test2-ignoreCase property is not set");
}

出力

Test1-ignoreCase property is not set
Test2-ignoreCase property is set