Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript global property

JavaScript global property

RegExp Object Reference JavaScript RegExp Object


Definition and Usage

The global property returns whether the regular expression has "g" .

If the g flag is set, this property is true; otherwise it is false.

Syntax

RegExpObject.global


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the global property.


Example

Example

Check whether the regular expression has the g flag:

var

str

=

"

Visit RUNOOB!

"

;

var

patt1

=/

RUN

/

g

;

if

(

patt1

.

global

)

{

document

.

write

(

"

The g flag is set!

"

)

;

}

else

{

document

.

write

(

"

The g flag is not set!

"

)

;

}

Try it »


RegExp Object Reference JavaScript RegExp Object