in reply to (Regex Madness) And you thought whitespace was easy.
Update: True enough japhy, but I said I was cheating :) And even though it scans the string three times, its simple and quicker than doing the reversing, lookaheads & lookbehinds necessary to do it in one regex.# If you have any spare characters to use # (lets say '~') sub my_squish { local $_ = shift; s/\n{2}/~/g; s/\s+/ /g; s/~/\n\n/g; $_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: (Regex Madness) And you thought whitespace was easy.
by japhy (Canon) on Aug 15, 2001 at 09:24 UTC | |
by runrig (Abbot) on Aug 15, 2001 at 11:32 UTC |