In my XML files, there are unicode line breaks like shown in this screenshot.
Use this link to see the screenshot
The two dots after “minds.” is the line break. I’ve googled and tried almost everything I know to replace them with ruby (1.8) but without any luck.
Here’s my code (with different tries of unicodes), maybe someone could help me.
def formatedBody
t = self.body.gsub("\u000a","<br/>")
t = t.gsub("\u000d","<br/>")
t = t.gsub("\u0009","<br/>")
t = t.gsub("\u000c","<br/>")
t = t.gsub("\u0085","<br/>")
t = t.gsub("\u2028","<br/>")
t = t.gsub("\u2029","<br/>")
t = t.gsub(/0A\0A/u,"<br/>")
return t
end
The two
0x0Avalues are the hex representation of line-feeds. Regular ol’ ASCII line feeds, AKA"\n\n"in a string.So,
t = t.gsub(/\n/, "<br/>")should work.You can replace the list of OR’d characters with:
Either way, the output would look like:
The reason your
doesn’t work is the regex is not correct.
is an alternate way of defining: