Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Answer: How do I remove whitespace at the beginning or end of my string?

by btrott (Parson)
on Mar 03, 2000 at 23:57 UTC ( #4826=categorized answer: print w/replies, xml ) Need Help??

Q&A > regular expressions > How do I remove whitespace at the beginning or end of my string? - Answer contributed by btrott

You could also do this in just one step. Use foreach's aliasing behavior to write this:
for ($string) { s/^\s+//; s/\s+$//; }

  • Comment on Answer: How do I remove whitespace at the beginning or end of my string?
  • Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[Corion]: marto: Yeah - their mother picked all three of them up at the kindergarden to then go to the hospital, and all three of them were well behaved, and all also were quite obedient when they came home, so they recognized the situation
[Corion]: Nice to see that the kids have some understanding of important things that happen and the appropriate behaviour :)
[marto]: at times mine surprise me with this behavior :)

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2016-12-08 09:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (137 votes). Check out past polls.