1 | The substitution operator s has the form: |
2 | $line =~ s/regex1/regex2/ ; |
3 | As with m, the operator s can use any delimiter and so |
4 | $line =~ s#regex1#regex2# ; |
5 | is an equivalent form |
6 | In the substitution s/regex1/regex2/g the /g causes substitution to occur at all possible places in string (normally only the first match is found) |
7 | Note that /i and /g can be used together |
8 | In an HTML doc, replace 2x2 with <NOBR>2 x 2 </NOBR> |
9 | Search: (\d+)x(\d+) |
10 | Replace: <NOBR>\1 x \2</NOBR> |
11 | PERL: s|(\d+)x(\d+)|<NOBR>\1 x \2</NOBR>|i |