JavaScript RegExp * Quantifier
Example 1
A global search for an "l", followed by zero or more "o" characters:
let text = "Hellooo World! Hello W3Schools!";
let pattern = /lo*/g;
Try it Yourself »
Description
The n* quantifier matches any string that contains zero or more occurrences of n.
Example 2
A global search for a "1", followed by zero or more "0" characters:
let text = "1, 100 or 1000?";
let pattern = /10*/g;
Try it Yourself »
Browser Support
/n*/
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
Syntax
new RegExp("n*")
or simply:
/n*/
Syntax with modifiers
new RegExp("n*", "g")
or simply:
/n*/g
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.