JavaScript RegExp {X} quantifier
Definition and Usage
n{XThe {X} quantifier matches a string containing exactly X n occurrences of the preceding sequence.
X Must be a number.
Syntax
new RegExp("
n
{
X
}")
Or a simpler way:
/
n
{
X
}/
Browser support





All major browsers support the {X} quantifier.
Example
Example
Perform a global search for substrings containing a sequence of four digits:
var str="100, 1000 or 10000?";
var patt1=/d{4}/g;
Match four digits:
var
str
=
"
100, 1000 or 10000?
"
;
var
patt1
=/\
d
{
4
}
/
g
;
Try it »
The JavaScript RegExp object