title: Javascript RegExp and boundaries
body: <p>A colleague asked me about a Regular expression problem, and I can't seem to find and answer for him.</p>
  
  <p>We're using boundaries to highlight certain lengths of text in a text editor, but here's some sample code that shows the problem:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var str = "Alpha , Beta, Gamma Delta Epsilon, AAlphaa, Beta Alpha&lt;br/&gt;";
  var rx = new RegExp('\bAlpha\b','gim');
  
  document.write(str.replace(/\b(Alpha)\b/gim, '-- $1 --'));
  document.write(str.replace(rx, '== $1 =='));
  &lt;/script&gt;
  </code></pre>
  
  <p>The issue is, the first literal str.replace works, but the RegExp option doesn't.</p>
  
  <p>I've got the same behaviour in IE and FF, anyone know why ?</p>