Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://443392]
help
Chatterbox?
[nysus]: so, I can't seem to post to perlmonks
[nysus]: I just get a "preview" button but no way to submit

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2017-12-15 03:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (416 votes). Check out past polls.

    Notices?