Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: trim leading & trailing whitespace

by BrowserUk (Pope)
on Mar 30, 2005 at 08:06 UTC ( #443368=note: print w/ replies, xml ) Need Help??

in reply to trim leading & trailing whitespace


Update: Corion rightly points out that this does not work correctly for lines where the last non whitespace character is a non-words character. Eg.

the quick brown fox ( \n # ^

So, use s[^\s*(.*\S)\s*$][]; instead. It's slower, but still quicker than the FAQ method.

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco.
Rule 1 has a caveat! -- Who broke the cabal?

Comment on Re: trim leading & trailing whitespace
Select or Download Code
Replies are listed 'Best First'.
Re^2: trim leading & trailing whitespace
by ady (Deacon) on Mar 30, 2005 at 08:46 UTC
    Good one too (needs the gm modifiers to do the job tho') -- allan

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2015-11-28 04:48 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (737 votes), past polls