in reply to Re: substitute leading whitespace
in thread substitute leading whitespace
ikegami, maybe I'm misunderstanding your second reason, but I don't think it is correct, because it implies that, under the /g modifier, prior substitutions affect subsequent matches, but consider the following variant of the original example:
If I understood your second reason correctly, according to it the printout would have been:my $s = ' this is a string'; ( my $t = $s ) =~ s/(?<!\w)\s/X/g; print $t, $/; __END__ XXXthis is a Xstring
because after the first substitution the second space no longer matches the first part of the s///.X Xthis is a Xstring
the lowliest monk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: substitute leading whitespace
by ikegami (Patriarch) on Jun 10, 2005 at 14:59 UTC | |
by tlm (Prior) on Jun 11, 2005 at 18:55 UTC |