JavaScript RegExp d Modifier
Example
Match every text that starts or ends with aa or bb:
let text = "aaaabb";
let result = text.match(/(aa)(bb)/d);
Try it Yourself »
More examples below.
Description
The "d" modifier specifies the start and end of match.
The "d" modifier is case-sensitive.
Browser Support
/regexp/d
is an ES2022 feature.
JavaScript 2022 (ES2022) is supported in all modern browsers since March 2023:
Chrome 94 | Edge 94 | Firefox 93 | Safari 16.4 | Opera 79 |
Sep 2021 | Sep 2021 | Oct 2021 | Mar 2023 | Oct 2021 |
Syntax
new RegExp("regexp", "d")
or simply:
/regexp/d
Regular Expression Search Methods
In JavaScript, a regular expression text search, can be done with different methods.
With a pattern as a regular expression, these are the most common methods:
Example | Description |
---|---|
text.match(pattern) | The String method match() |
text.search(pattern) | The String method search() |
pattern.exec(text) | The RexExp method exec() |
pattern.test(text) | The RegExp method test() |