[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Hi-bit characters in regex's



htp@metropolis.net.au (Henry Penninkilampi) wrote:
>If you want to strip spaces from both ends of a string, the following 
>will do it for you on a single line:
>
> $old_string =~ s/^(\s*)(.+)(\s*)$/$2/;

[...]

>Nothing to do with the topic, but I just thought you might want to know 
>the easier way.

But it's quite a bit slower and more of a memory hog.  Better to do it
with two regexes and no memory-parens.  And make sure to use + , not * .

	$old_string =~ s/^\s+//;
	$old_string =~ s/\s+$//;


  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  ken@forum.swarthmore.edu                            The Math Forum



# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org