Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: trimming space from both sides of a string

by GrandFather (Saint)
on Oct 16, 2010 at 06:20 UTC ( [id://865631]=note: print w/replies, xml ) Need Help??


in reply to Re: trimming space from both sides of a string
in thread trimming space from both sides of a string

It seems likely (without benchmarking) that those two substitutions (s/^\s.*//; s/\s.*$//;) are very efficient at removing leading and trailing white space. However the side effect of removing everything if there is leading or trailing white space may be too much of a price to pay for "efficiency"!

True laziness is hard work

Replies are listed 'Best First'.
Re^3: trimming space from both sides of a string
by mr_mischief (Monsignor) on Oct 16, 2010 at 16:04 UTC
    oh! Right! No dot in there. s/^\s*//; s/\s*$//; instead of course. s/^\s+//; s/\s+$//; should work as well.

      s/^\s+//; s/\s+$//; works better than s/^\s*//; s/\s*$//;.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-24 07:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found