RegExp /d Flag
Example
Match every sub text that starts or ends with aa or bb:
let text = "aaaabb";
let result = text.match(/(aa)(bb)/d);
Try it Yourself »let result = text.match(/(aa)(bb)/d);
Description
The/d flag specifies the start and the end of a match.
Syntax
new RegExp("regexp", "d")
or simply:
/regexp/d
or simply:
/regexp/d
See Also:
The Corresponding Property:hasIndices
Regular Expression Methods
Regular ExpressionSearch andReplace can be done with different methods.
These are the most common:
String Methods
| Method | Description |
|---|---|
| match(regex) | Returns an Array of results |
| matchAll(regex) | Returns an Iterator of results |
| replace(regex) | Returns a new String |
| replaceAll(regex) | Returns a new String |
| search(regex) | Returns the index of the first match |
| split(regex) | Returns an Array of results |
RegExp Methods
| Method | Description |
|---|---|
| regex.exec() | Returns an Iterator of results |
| regex.test() | Returns true or false |
Browser Support
/regexp/d is a JavaScript 2022 feature.
ES 2022 is supported in all modern browsers sinceMarch 2023:
| Chrome 94 | Edge 94 | Firefox 93 | Safari 16.4 | Opera 79 |
| Sep 2021 | Sep 2021 | Oct 2021 | Mar 2023 | Oct 2021 |

