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





All major browsers support the {X,Y} quantifier.
Example
Example
Perform a global search for substrings containing a sequence of three or four digits:
var
str
=
"
100, 1000 or 10000?
"
;
var
patt1
=/\
d
{
3
,
4
}
/
g
;
The text marked below shows where the expression found matches:
100
,
1000
or
1000
0?
Try it »
The JavaScript RegExp object