title: RegExp - replace quote doesn't work
body: <p>I would like to replace variable <code>str'</code> with <code>&lt;span class="red"&gt;str'&lt;/span&gt;</code>, but I always get the <code>"'"</code> outeside of the span. I wrote the following javascript:</p>
  
  <pre><code>var f1="XY+X'Y";
  var str=X;
  var patt=new RegExp(str+'\'',"g");
  f1.replace(patt, "&lt;span class=\"red\"&gt;"+str+"'"+"&lt;/span&gt;")
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>&lt;span class="red"&gt;X&lt;/span&gt;';
  </code></pre>
  
  <p>I want:</p>
  
  <pre><code>&lt;span class="red"&gt;X'&lt;/span&gt;;
  </code></pre>