RegExp x{n} Quantifier
A global search for a string that contains a sequence of four digits:
let text = "100, 1000 or 10000?";
let pattern = /\d{4}/g;
let result = text.match(pattern);
Try it Yourself »
Description
The x{n} quantifier matches n occurences of x.
n must be a number.
Syntax
new RegExp("x{n}")
or simply:
/x{n}/
Syntax with modifiers
new RegExp("x{n}", "g")
or simply:
/x{n}/g
Browser Support
/{n}/
is an ECMAScript1 (JavaScript 1997) feature.
It is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |