Latest web development tutorials

RegExp * quantifier

RegExp Object Reference JavaSript RegExp objects

Definition and Usage

n *quantifier matches any string that contains zero or moreof n.

grammar

new RegExp("n*")

或者更简单方式:

/n*/


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support * quantifier


Examples

Example 1

Of the "l" global search, including immediately followed by one or more "o":

var str="Hellooo World! Hello W3Schools!";
var patt1=/lo*/g;

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

He llooo Wor l d! He llo W3Schoo l s!

try it"

Example 2

To "1" in the global search, including immediately followed by one or more "0":

var str="1, 100 or 1000?";
var patt1=/10*/g;

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

1 , 100 or 1000 ?

try it"


RegExp Object Reference JavaSript RegExp objects