Or just match the bits you care about:<br><br> $line =~ s/^\s+|\s+$//g;<br><br><div class="gmail_quote">On Tue, May 4, 2010 at 1:35 PM, Steve Fink <span dir="ltr"><<a href="mailto:sphink@gmail.com">sphink@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">You might want to also make those +s into *s... (you're requiring<br>
lines to have whitespace on *both* sides before you'll fix 'em.)<br>
<div><div></div><div class="h5"><br>
On Tue, May 4, 2010 at 1:02 PM, Joe Brenner <<a href="mailto:doom@kzsu.stanford.edu">doom@kzsu.stanford.edu</a>> wrote:<br>
><br>
> David Alban wrote:<br>
>> it's so easy to miss the error in:<br>
>><br>
>> $line =~ s{ s+ \z }{}xms;<br>
>><br>
>> when you expect to see:<br>
>><br>
>> $line =~ s{ \s+ \z }{}xms;<br>
>><br>
>> i wondered why one of the lines was having its last character stripped<br>
>> but the others were ok.<br>
><br>
> The one I like is<br>
><br>
> $line =~ s{ ^ \s+ (.*?) \s+ $ }{ $1 }x;<br>
><br>
> It always takes me awhile to figure out why the leading and<br>
> trailing spaces aren't all going away.<br>
><br>
> (I need a \X modifier that makes spaces insignificant in the<br>
> replace string as well as in the find pattern.)<br>
><br>
> _______________________________________________<br>
> SanFrancisco-pm mailing list<br>
> <a href="mailto:SanFrancisco-pm@pm.org">SanFrancisco-pm@pm.org</a><br>
> <a href="http://mail.pm.org/mailman/listinfo/sanfrancisco-pm" target="_blank">http://mail.pm.org/mailman/listinfo/sanfrancisco-pm</a><br>
><br>
_______________________________________________<br>
SanFrancisco-pm mailing list<br>
<a href="mailto:SanFrancisco-pm@pm.org">SanFrancisco-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/sanfrancisco-pm" target="_blank">http://mail.pm.org/mailman/listinfo/sanfrancisco-pm</a><br>
</div></div></blockquote></div><br>