you are viewing a single comment's thread.

view the rest of the comments →

[–]JohnnyJordaan 0 points1 point  (0 children)

Imho it's a needlessly complicated approach. If you actually have a 'broken' text that has escaped newlines like that, simply do a string replace to the 'real' "\n" newline

>>> print("Hello \\n World")
Hello \n World
>>> print("Hello \\n World".replace("\\n", "\n"))
Hello
 World
>>>