I'm looking for a solution to replace the newline characters found inside an XML's attributes (XML string) in Javascript. (Trying to replace with
so I do not lose newlines when parsing XML back)
Note: There are other newlines in the string, e.g after <main> .. </body>
(Open to any other regex/non-regex solutions!)
<main>
<head/><body><note text="Load">
<note text="2 Newlines at the end of this
newline"/>
</body>
</main>
All I have is this awful thing "[\s\S]*?([\r\n]+)[\s\S]*?"