JavaScript RegExp * quantifier
The JavaScript RegExp object
Definition and Usage
nThe * quantifier matches a string containing zero or more n .
Syntax
new RegExp("
n
*")
Or a simpler way:
/
n
*/
Browser support





All major browsers support the * quantifier
Example
Example 1
Perform a global search for "l", including zero or more "o" immediately following it:
var str="Hellooo World! Hello Runoob!";
var patt1=/lo*/g;
The text marked below shows where the expression found matches:
He
llooo
Wor
l
d! He
llo
Runoob!
Try it »
Example 2
Perform a global search for "1", including one or more "0" immediately following it:
var str="1, 100 or 1000?";
var patt1=/10*/g;
The text marked below shows where the expression found matches:
1
,
100
or
1000
?
Try it »
The JavaScript RegExp object