Latest web development tutorials

RegExp {X} quantifier

RegExp Object Reference JavaSript RegExp objects

Definition and Usage

n{X,} quantifier matches strings comprising the sequence of Xn's.

Xmust be numeric.

grammar

new RegExp("n{X}")

或者更简单方式:

/n{X}/


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support {X} quantifier.


Examples

Examples

Of the sub-sequence contains a four-digit string global search:

var str="100, 1000 or 10000?";
var patt1=/d{4}/g;

The marked text below shows where the expression gets a match:

100, 1000 or 1000 0?

try it"


RegExp Object Reference JavaSript RegExp objects