JavaScript globalProperty

RegExp 对象参考手册JavaScript RegExp Object

Definition and Usage

The global property is used to return 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 EXAMPLE!"; var patt1=/RUN/g; if(patt1.global) { document.write("The g mode is set!"); } else { document.write("The g mode is not set!"); }

Try it Yourself »


RegExp 对象 参考手册JavaScript RegExp Object Other Extensions