title: Using javascript regex to replace a character entity
body: <p>I have a set of notes which aren't displaying properly. Looking at the source, there is <code>&amp;#xd;&amp;#xa;</code> where the line breaks should be. I want to replace these instances with <code>&lt;br&gt;</code>. I've used a bookmarklet which will work for a plaintext string such as <code>ABC</code> but it won't work for the given string. </p>
  
  <p>For example, this one works fine:</p>
  
  <p><code>javascript:(function(){var re = new RegExp("ABC", "g"); document.getElementById('my_span').innerHTML=document.getElementById('my_span').innerHTML.replace(re, "&lt;br&gt;" );})();</code></p>
  
  <p>Whereas this doesn't:</p>
  
  <p><code>javascript:(function(){var re = new RegExp("&amp;#xd;&amp;#xa;", "g"); document.getElementById('my_span').innerHTML=document.getElementById('my_span').innerHTML.replace(re, "&lt;br&gt;" );})();</code></p>
  
  <p>Oddly the latter will take the first instance of <code>&amp;#xd;&amp;#xa;</code> and just remove it without replacing it. </p>
  
  <p>The page I'm working with does not load jQuery and I'm working in a corporate environment so I'm loathe to call something external.</p>
  
  <p>Is this to do with with <code>innerHTML</code> not receiving the <code>&amp;#xd;&amp;#xa;</code> as I expect it to? Thanks very much for your help.</p>