Uri, my apologies, you did say use $1 in the replacement side and I missed that.  yes, agreed, use $1 on the replacement side, \1 on the match side.<br><br><div class="gmail_quote">On Sun, Oct 28, 2012 at 6:45 AM, Rob Janes <span dir="ltr"><<a href="mailto:janes.rob@gmail.com" target="_blank">janes.rob@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">ok, if you don't believe me when I say it doesn't work, try it yourself then.<br><br>[robj@rj-ul80vt ~]$ perl -e '$x = "one \t\t two"; print "$x\n"; $x =~ s/(\s)$1+/\1/; print "$x\n";'<br>

one          two<br>one two<br>[robj@rj-ul80vt ~]$ perl -e '$x = "one \t\t two"; print "$x\n"; $x =~ s/(\s)\1+/\1/; print "$x\n";'<br>one          two<br>one      two<br><br>notice that the usage of $1 resulted in a mixed string of whitespace being substituted.  only the tabs should have been substituted, not everything.<br>

<br>therefore, the $1 in the matching regex resolved to \s not space.<div class="HOEnZb"><div class="h5"><br><br><div class="gmail_quote">On Sat, Oct 27, 2012 at 11:52 PM, Uri Guttman <span dir="ltr"><<a href="mailto:uri@stemsystems.com" target="_blank">uri@stemsystems.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On 10/27/2012 07:42 PM, Rob Janes wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Slurp the file and run the second regex.<br>
<br>
undef $/;<br>
$exp = <in>;<br>
</blockquote></div>
use File::Slurp is much better for that.<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
$exp =~ s/(\s)\1+/\1/g;<br>
</blockquote>
<br></div>
i keep saying to not use \1 in the replacement. it is documented to be wrong but supported. don't use it there. use $1<span><font color="#888888"><br>
<br>
uri</font></span><div><div><br>
______________________________<u></u>_________________<br>
toronto-pm mailing list<br>
<a href="mailto:toronto-pm@pm.org" target="_blank">toronto-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/toronto-pm" target="_blank">http://mail.pm.org/mailman/<u></u>listinfo/toronto-pm</a><br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>