Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Re: Re: Re: remove both leading and trailing spaces

by the_0ne (Pilgrim)
on Sep 26, 2003 at 20:46 UTC ( #294540=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Re: remove both leading and trailing spaces
in thread remove both leading and trailing spaces

One thing you want to watch with regex2...

regex2 => sub { my $tmp = $val; $val = join (" ",split " ",$val); },
... is if the variable has spaces contained in the phrase that you want to keep, this will get rid of them...
$var = " Smart Way "; $val = join (" ",split " ",$val); print "var: $var\n"; # $var now "Smart Way", internal spaces gone.
regex1 and regex2 would retain the internal spaces.


Comment on Re: Re: Re: Re: remove both leading and trailing spaces
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://294540]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2014-09-16 12:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (17 votes), past polls