Saturday, 26 March 2016

XML : Match newline characters inside quotes

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> https://regex101.com/r/vE2lD7/2 (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]*?"

https://regex101.com/r/vE2lD7/2

No comments:

Post a Comment