JavaScript RegExp {X} Quantifier

Definition and Usage

n{Xquantity matching the following characters: X number of n string sequence.

X Must be a number.

Example

Global search for substrings containing a sequence of four digits:

let text = "100, 1000 or 10000?";
let pattern = /\d{4}/g;

Try it yourself

Syntax

new RegExp("n{X}")

or abbreviated as:

/n{X}/

Syntax with Modifiers

new RegExp("n{X}", "g")

or abbreviated as:

/n{X}/g

Browser Support

/n{X}/ Is ECMAScript1 (ES1) feature.

All browsers fully support ES1 (JavaScript 1997):

Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support