Latest web development tutorials

RegExp {X, Y} quantifier

RegExp Object Reference JavaSript RegExp objects

Definition and Usage

n{X, Y} quantifier matches comprising at least a sequence of X up to Y n of a string

XandYmust be numeric.

grammar

new RegExp("n{X,Y}")

或者更简单方式:

/n{X,Y}/


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support {X, Y} quantifier.


Examples

Examples

Of the sub-sequence contains three or four digits of the global search string:

var str="100, 1000 or 10000?";
var patt1=/d{3,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