http://www.perlmonks.org?node_id=443390


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

Hi bart

In the example I gave above,

 s/^\s*(.*?)\s*$/$1/gm

the combination of the \m modifier, and the line anchors ^ and $ will ensure the newlines are left alone

cheers

thinker