JavaScript RegExp d modifier

Definition and usage

"dThe modifier specifies the start and end positions of the match.

"dThe modifier distinguishes between uppercase and lowercase.

Example

Match all text that starts or ends with aa or bb:

let text = "aaaabb";
let result = text.match(/(aa)(bb)/d);

Try it yourself

Syntax

new RegExp("regexp", "d")

Or abbreviated as:

/regexp/d

Regular expression search methods

In JavaScript, different methods can be used for regular expression text search.

When the pattern is a regular expression, the following are the most commonly used methods:

Example Description
text.match(pattern) String method match()
text.search(pattern) String method search()
pattern.exec(text) RexExp method exec()
pattern.test(text) RexExp method test()

Browser support

/regexp/d It is a feature of ES2022.

Starting from March 2023, all modern browsers support JavaScript 2022 (ES2022):

Chrome Edge Firefox Safari Opera
Chrome 94 Edge 94 Firefox 93 Safari 16.4 Opera 79
September 2021 September 2021 October 2021 March 2023 October 2021