From http://www.w3schools.com (Copyright Refsnes Data)

JavaScript RegExp g Modifier


RegExp Object Reference 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:

Is this all there is?

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:

Is this all there is?

Try it yourself »


RegExp Object Reference JavaScript RegExp Object

From http://www.w3schools.com (Copyright Refsnes Data)