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

Re^2: trim leading & trailing whitespace

by ihb (Deacon)
on Mar 30, 2005 at 10:09 UTC ( #443392=note: print w/ replies, xml ) Need Help??


in reply to Re: trim leading & trailing whitespace
in thread trim leading & trailing whitespace

\s matches newlines too, meaning that your pattern will remove empty lines, not just trim them. An alternative is

s/^[^\S\n]+//gm; s/[^\S\n]+$//gm;

ihb

See perltoc if you don't know which perldoc to read!


Comment on Re^2: trim leading & trailing whitespace
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2015-07-29 05:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls