Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Strip leading and trailing blanks

by fruiture (Curate)
on Jul 29, 2003 at 21:16 UTC ( [id://278995]=note: print w/replies, xml ) Need Help??


in reply to Strip leading and trailing blanks

Because this is a common problem (and _has_ been answered here before) i can tell that there is a very efficient way to do it (probably the most efficient one of the less complicated):

s/^\s+//; s/\s+$//;

See perlop and perlre.

--
http://fruiture.de

Replies are listed 'Best First'.
Re: Re: Strip leading and trailing blanks
by Kanji (Parson) on Jul 29, 2003 at 22:22 UTC

    Check out trim() by japhy... a really neat sub that wraps and builds upon this very solution.

        --k.


Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-03-28 21:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found