Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

RegExp {X,Y} quantifier

JavaScript RegExp {X,Y} quantifier

RegExp Object Reference The JavaScript RegExp object


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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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 »


RegExp Object Reference The JavaScript RegExp object