Latest

recent

JavaScript RegExp * Modifier

Definition and Usage

When the * modifier is set the regular expression finds zero or more of a specific character.

Syntax

new RegExp("regexp*")
OR
/regexp*/

Parameter Description
regexp Required. The rest of the regular expression to use


Example

In the following code we will do a global search for any substring with a 1 followed by zero or more "0" characters:

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

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

1, 100 or 1000?
JavaScript RegExp * Modifier Reviewed by 1000sourcecodes on 21:41 Rating: 5
Powered by Blogger.