ok, I have the following, very simple code:
f = \"String1\\n\\n\\nString2\\n\\n\\n\" f.each_line do |t| t.delete! \"\\n\" puts t.inspect end
You could split the string by \n, and then reject any blank lines:
\n
f = "String1\n\n\nString2\n\n\n" f.split("\n").reject { |i| i.empty? } #=> ["String1", "String2"]
You'd end up with an Array that you can output as you'd like.