Skip to main content

What is "/g" in Regular expression?

Being a techno geek i was searching an answer , what is the use of "/g" in regular expression.Usually while writing regular expression we add /g at the end of the regular expression .
for example, there is a regular expression     /[^a-zA-Z0-9 ]/g
.The answer is simple: The g on the end after the  / means do a global replace - if you leave it off then only the first match will be replaced.


Cheers
Pradeepa achar

Comments