Carl Jolley [mailto:[EMAIL PROTECTED]] wrote: > 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; I had this thought as well but it fails since the .* term will suck up the trailing whitespace (due to greedy matching). Changing (.*) to (.*?) resolves this, but starts to look seriously like line noise... :-) Aldo's $str =~ s/^\s+|\s+$//g; is an interesting twist that I have never seen before. However, I suspect two simple regexs will still be faster than the overhead caused by the alternation combined with the global modifier. cheers, bj -- Brad Warkentin CAD Manager AcceLight networks email: [EMAIL PROTECTED] www.accelight.com phone: 613.596.4804 x4388 26 Auriga Drive fax: 613.596.2399 Ottawa, ON K2E 8B7 _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs