title: remove extra space, line breaks and $nbsp from a string javascript
body: <p>how can I turn this </p>
  
  <pre><code>\n            &lt;!DOCTYPE html &gt;\n            &lt;html&gt;\n                &lt;body&gt;\n                &lt;p&gt;test&amp;nbsp;&amp;nbsp;&lt;/p&gt;\n                &lt;select multiple=\"multiple\"&gt;\n                    &lt;option value=\"1\" correct=\"true\"&gt;red&lt;/option&gt;&lt;option value=\"2\" correct=\"false\"&gt;Blue&lt;/option&gt;\n                &lt;/select&gt;\n                &lt;p visible-if=\"correct\"&gt;Yeah correct&lt;/p&gt;\n                &lt;p visible-if=\"wrong\"&gt;Wrong dude&lt;/p&gt;\n                &lt;/body&gt;\n            &lt;/html&gt;\n 
  </code></pre>
  
  <p>into this</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;body&gt;&lt;p&gt;test&lt;/p&gt;&lt;select multiple="multiple"&gt; &lt;option value="1" correct="true"&gt;red&lt;/option&gt;&lt;option value="2" correct="false"&gt;Blue&lt;/option&gt;&lt;/select&gt;&lt;p visible-if="correct"&gt;Yeah correct&lt;/p&gt;&lt;p visible-if="wrong"&gt;Wrong dude&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>using <strong>javascript</strong> ?</p>
  
  <p>I've tried following code. but could not get this to work</p>
  
  <pre><code>.replace(/\r?\n?\s+/g, '').trim();
  </code></pre>