Match newline characters inside quotes
<p>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 <code>&amp;#10;</code> so I do not lose newlines when parsing XML back)</p>

<p><strong>Note:</strong> There are other newlines in the string, e.g after <code>&lt;main&gt; .. &lt;/body&gt;</code></p>

<p>(Open to any other regex/non-regex solutions!)</p>

<pre><code>&lt;main&gt;
&lt;head/&gt;&lt;body&gt;&lt;note text="Load"&gt; 
&lt;note text="2 Newlines at the end of this    

newline"/&gt;
&lt;/body&gt;
&lt;/main&gt;
</code></pre>

<p>All I have is this awful thing <code>"[\s\S]*?([\r\n]+)[\s\S]*?"</code></p>

<p><a href="https://regex101.com/r/vE2lD7/2" rel="nofollow">https://regex101.com/r/vE2lD7/2</a></p>