in reply to Replacing \n even when it shouldn't be :/

Why the /s and /i modifiers?

Basically what you want is to replace any non-empty string of whitespace with either a newline (if the string contains a newline), or with a space. Here's a 5.10 way of doing it:

s/(?:\s*\n\s*(*:N))|(?:\s{2,}(*:S))/{"N","\n","S"," "}->{our $REGMARK} +/ge;