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

RegExp {X,} quantifier

JavaScript RegExp {X,} quantifier

RegExp Object Reference The JavaScript RegExp object


Definition and Usage

n{XThe {X,} quantifier matches a string containing at least 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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the {X,} quantifier


Example

Example

Perform a global search for substrings containing a sequence of at least three digits:

var

str

=

"

100, 1000 or 10000?

"

;

var

patt1

=/\

d

{

3

,

}

/

g

;

The text marked below shows where the expression found matches:

100

,

1000

or

10000

?

Try it »


RegExp Object Reference The JavaScript RegExp object