Problems? Is your data what you think it is? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Keystone,
I am relatively new here at perlmonks, but perhaps I can help a little bit. You asked why the regexp matched only once, instead of multiple times. This is so because it is a FEATURE of the rules of regex to only do so unless something like the "global" switch is added *at the end of the regex in play*. If you invoke the global switch, then all matches will be replaced with the substitution string. So, if you had some code: $_="FourThreeTwoOne, Three, Four, One, Two"; $1="Three"; $second="&&&&"; s/$2/$second/g; print; it would print this result: Four&&&&TwoOne, &&&&, Four, One, Two Hope this helps. -HaT In reply to Re^3: RegExp substitution
by HereandThere
|
|