user2950593 user2950593 - 6 months ago 26
Ruby Question

replace \t\t characters with <br> character rails

I am making a parser of some website.
As an output from parser I get string like:

"some text \t\t some another text \t\t another text"


I want to replace
\t\t
with
<br>
. How can I do this?

Answer

Use gsub:

"some text \t\t some another text \t\t another text".gsub("\t\t", "<br>")
=> "some text <br> some another text <br> another text"
Comments