Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2021年9月.
hasIndices は RegExp インスタンスのプロパティで、その正規表現で d フラグが使用されたかどうかを示します。
RegExp.prototype.hasIndices の値は d フラグが使用されている場合に true となり、そうでない場合は false となります。d フラグは、正規表現の照合結果に各キャプチャグループの部分文字列の開始と終了のインデックスを含めることを示します。これは正規表現の解釈や照合の動作を変更するものではなく、照合結果に追加情報を与えるだけです。
このフラグは、主に exec() の返値に影響します。d フラグが存在する場合、exec() によって返される配列は、exec() メソッドの返値に記述されているように、追加の indices プロパティを持ちます。他のすべての正規表現関連のメソッド(String.prototype.match() など)は、内部的に exec() を呼び出すので、正規表現に d フラグがある場合、インデックスも返します。
hasIndices の設定アクセサーは undefined です。このプロパティを直接変更することはできません。
グループと後方参照 > グループと一致結果の添字の使用に詳しい使用例があります。
| ECMAScript® 2027 Language Specification # sec-get-regexp.prototype.hasIndices |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年11月10日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.