JavaScript global property
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





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 »
JavaScript RegExp Object