Javascript to remove trailing &nbsp;
<p>I am getting a string which is nothing but innerHTML, and so it has instances of <code>&amp;nbsp;</code>. I need to trim the string such that the trailing <code>&amp;nbsp;</code> alone are removed.
Tried this:</p>

<blockquote>
  <p>var text; <br>
  text = txtInnerHTML.replace(/(<code>&amp;nbsp;</code>)*/g,"");</p>
</blockquote>

<p>This removes all instances of <code>&amp;nbsp;</code> which is not desired.. Only the <strong>trailing</strong> <code>&amp;nbsp;</code> instances may be which may be zero or more need to be removed.</p>
