|
|
JavaScript RegExp g Modifier
JavaScript RegExp Object
Definition and Usage
The g modifier is used to perform a global match (find all matches rather
than stopping after the first match).
Syntax
new RegExp("regexp","g")
or simply:
/regexp/g
|
Examples
Example 1
Do a global search for "is":
var str="Is this all there is?";
var patt1=/is/g; |
The marked text below shows where the expression gets a match:
Try it yourself »
|
Example 2
Do a global, case-insensitive search for "is":
var str="Is this all there is?";
var patt1=/is/gi; |
The marked text below shows where the expression gets a match:
Try it yourself »
|
JavaScript RegExp Object
|
|
|