How can I change one or more line breaks to something in ruby?
article.content.gsub(/\n/, "<br />")
above code will change every 1 line break to <br /> tag, however, I want to change one or more \n to <br /> tag. In that way, continuous line breaks with empty lines will be substitued into a single <br /> tag.
How can I do that?
Are you looking for this?
Note the plus sign after the
\n. That will change any sequence of one or more newlines to a single<br>.