in reply to regex doubt on excluding
The "big hammer" approach says replace all of those characters with a newline.
s/^\s*$/\n/mg;
I'm a fan of the big hammer approach, but as you'd expect subtlety isn't exactly my strong point.