JavaScript RegExp {X,Y}Quantifier
Definition and Usage
n{X,Y} Quantifier matches strings containing at least X and at most Ynof the sequence of strings
XandYMust be a number.
Syntax
new RegExp("n{X,Y}")
Or a simpler way:
/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 sequences of three or four digits:
var str="100, 1000 or 10000?";
var patt1=/\d{3,4}/g;
Belowmarkedtext shows the positions where the expression gets a match:
100, 1000 or 10000?
Try it Yourself »
Other Extensions
JavaScript RegExp Object