RegExpx{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 »let pattern = /\d{4}/g;
let result = text.match(pattern);
Description
Thex{n} quantifier matchesn occurences ofx.
n must be a number.
Syntax
new RegExp("x{n}")
or simply:
/x{n}/
or simply:
/x{n}/
Syntax with modifiers
new RegExp("x{n}", "g")
or simply:
/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 |

