JavaScript RegExp ? Modifier
Definition and Usage
When the ? modifier is set the regular expression finds zero or one 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 one "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:42
Rating: