Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2021.
The hasIndices accessor property of RegExp instances returns whether or not the d flag is used with this regular expression.
RegExp.prototype.hasIndices has the value true if the d flag was used; otherwise, false. The d flag indicates that the result of a regular expression match should contain the start and end indices of the substrings of each capture group. It does not change the regex's interpretation or matching behavior in any way, but only provides additional information in the matching result.
This flag primarily affects the return value of exec(). If the d flag is present, the array returned by exec() has an additional indices property as described in the exec() method's return value. Because all other regex-related methods (such as String.prototype.match()) call exec() internally, they will also return the indices if the regex has the d flag.
The set accessor of hasIndices is undefined. You cannot change this property directly.
There's a more detailed usage example at Groups and backreferences > Using groups and match indices.
| ECMAScript® 2027 Language Specification # sec-get-regexp.prototype.hasIndices |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 10, 2025 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.