I have a script written in ruby. I need to remove any duplicate newlines (e.g.)
\\n \\n \\n
to
\\n
My current
Simply calling split will also trim out all of your whitespace.
You need to pass \n to split
\n
>> "one ok \ntwo\n\nthree\n".split(/\n+/).join("\n") => "one ok \ntwo\nthree"