There's also:

$foo =~ s/^\s*//;

and if you want to strip leading and trailing spaces:

$foo =~ s/^\s*(.*?)\s*$/$1/;

Though some say that the two step:

$foo =~ s/^\s*//;
$foo =~ s/\s*$//;

is faster. There's also a module:

String::Strip

with a function

StripLTSpace()

and it's fore and aft variants that purports to be faster than the regex
substitution.  I haven't done any testing to verify performance on any of these.

Dave

A simple Q........
well i want to remove spaces if any in the beginning and end of a string.
how to do this...........

..



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to