I have a script written in ruby. I need to remove any duplicate newlines (e.g.)
\\n \\n \\n
to
\\n
My current
Use the more idiomatic String#squeeze instead of gsub.
String#squeeze
gsub
str = "a\n\n\nb\n\n\n\n\n\nc" str.squeeze("\n") # => "a\nb\nc"