2009/12/20 sftriman <dal...@gmail.com>:
> I use this series of regexp all over the place to clean up lines of
> text:
>
> $x=~s/^\s+//g;
> $x=~s/\s+$//g;
> $x=~s/\s+/ /g;
>

You can probably use $x=~s/^(\s+)|(\s+)$//g;

But I don't think it will use any less CPU than the 3 regex option,
the nature of Perl's regex engine being what it is.

-- 
Erez

"The government forgets that George Orwell's 1984 was a warning, and
not a blueprint"
http://www.nonviolent-conflict.org/ -- http://www.whyweprotest.org/

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to