Regular Expressions   «Prev 

Perl Substitution g Modifier

The global modifier (g) makes the replacement happen on all occurrences of the matched pattern.
For example, this will replace only the first occurrence of the with el:
s/the/el/


Perl modifiers (flags)*

Modifier Description
a Match \d, \s, \w and POSIX in ASCII range only
c Keep current position after match fails
d Use default, native rules of the platform
g Global matching
i Case-insensitive matching
l Use current locale�s rules
m Multiline strings
p Preserve the matched string
s Treat strings as a single line
u Use Unicode rules when matching
x Ignore whitespace and comments

But this will replace all occurrences:
s/the/el/g