title: Matching a non-breakable white space in IE7 and IE8 in Javascript
body: <p>I want to replace white spaces in any relatively modern browser (thus for IE, version >= 7).</p>
  
  <p>Thus given the string <code>"Hello world!"</code> we would do:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  document.write("Result: '" + "Hello world!".replace(/\s/g, '') + "'");
  &lt;/script&gt;
  </code></pre>
  
  <p>Which we would expect to output: <code>Result: 'Helloworld!'</code></p>
  
  <p>But in IE7 and IE8 though it fails using a non-breakable space like one of these: <code>&amp;#160;</code> == <code>&amp;nbsp;</code> == <code>\u00A0</code></p>
  
  <p>For example:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  document.write("Result: '" + String.fromCharCode(160).replace(/\s/g, '') + "'");
  &lt;/script&gt;
  </code></pre>
  
  <p>Will output <code>Result: 'Helloworld!'</code> in FF and IE >= 9 and <code>Result : ' '</code> in IE7 and IE8. What the hell?</p>
  
  <p>This makes me wonder if this is the only exception? I could not find much information about this at all. Is there maybe a Regular Expression which removes all white spaces <em>including</em> the non breakable?</p>