JavaScript RegExp *Quantifier

RegExp 对象参考手册JavaScript RegExp Object

Definition and Usage

n* Quantifier matches containing zero or morenany string.

Syntax

new RegExp("n*")

Or a simpler way:

/n*/


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support*the quantifier.


Examples

Example 1

Perform a global search for "l", including zero or more "o"s immediately following it:

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

Belowmarkedthe text shows the position where the expression obtains a match:

Hellooo World! Hello Example!

Try it yourself »

Example 2

Perform a global search for "1", including one or more "0"s immediately following it:

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

Belowmarkedthe text shows the position where the expression obtains a match:

1, 100 or 1000?

Try it yourself »


RegExp 对象参考手册JavaScript RegExp Object Other Extensions