On Fri, 5 Jul 2002, Lee Goddard wrote:

> At 07:59 05/07/2002, $Bill Luebkert wrote:
>
> >I'm afraid you will find that that is the fastest method except you
> >wrote it wrong - there is no need for the while {} part:
> >
> >my $str = "       this is a test files              ";
> >$str =~ s/^\s+//; $str =~ s/\s+$//;
> >print $str, "\n";
>
> What's wrong with:
>
>          s/^\s+(.*[^\s]+)\s+$/$1/sg;
>
> Surely something?
>

Perhaps because it won't match? There were imbedded spaces following the
multiple leading spaces and prior to the mutiple trailing spaces.
A variation on your regex that only looks at mutpile spaces might
work, e.g.

s/^\s{2,}(.*)\s{2,}$/$1/sg; or even

s/^\s*(.*)\s*$/$1/sg;

however I don't know that either of these two would be faster than the two
separate regex's that Bill used to strip the leading and trailing spaces.

**** [EMAIL PROTECTED] <Carl Jolley>
**** All opinions are my own and not necessarily those of my employer ****

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to