Home What's the meaning of /gi in a regex?
Post
Cancel

What's the meaning of /gi in a regex?

1
2
3
g modifier: global. All matches (don't return on first match)

i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])

In your case though i is immaterial as you don’t capture [a-zA-Z].

For input like [email protected]#$ if g modifier is not there regex will return first match ! See here.

If g is there it will return the whole or whatever it can match See here.

References

This post is licensed under CC BY 4.0 by the author.

Jekyll Chirpy Text and Typography

Escape the underscore and the percent when searching by like, ilike expressions in PostgreSQL