I have a string like this
"a a a a aaa b c d e f a g a aaa aa a a"
I want to turn it into either
"a b c d e f a g a"
or
"a b c d e f a g a "
(whichever’s easier, it doesn’t matter since it’ll be HTML)
"a"s are line breaks ( \r\n ), in case that changes anything.
Went with this:
It does, as it’s supposed to, ignore all line breaks except cases where it matches three or more continuous line breaks, ignoring whitespace, and replaces those matches with
\n\n.