title: How to add a javascript regular expression escape character dynamically
body: <p>I have a line of code as follows</p>
  
  <pre><code>if($('#eqInputBox').val().search( $(this).html() ) == -1)
  </code></pre>
  
  <p>Which is supposed to check to see the html is already in the eqInputBox or not - problem is, sometimes the character in <code>$(this).html()</code> can be a <code>'+'</code> or a <code>'*'</code>.  Any other character (in the set of possible characters for the app) works, but when these characters show up, the regular expression doesn't return any value - I think this might be because I can't slip a <code>\</code> character in to escape these characters.</p>
  
  <p>Anyone have any ideas on how, when the (this) html character is <code>+</code> or <code>*</code>, I can still make it check normally?</p>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>$(this).html()
  </code></pre>
  
  <p>is a user generated <code>div</code>, so I cannot simply put the escape character in manually. How would I go about dynamically adding it when it is necessary?</p>