title: jQuery: How to escape single and double quotes with backslash
body: <p>I want to escape single and double quotes with a backslash in one line rather than two.</p>
  
  <p>Example for single quote:</p>
  
  <pre><code>str = str.replace(/'/g, "\\'");
  </code></pre>
  
  <p>Is there a way to do this at the same time for double quotes included?</p>
  
  <p>Sniffer Answered this very well below, and I ended up escaping all characters we needed as follows:</p>
  
  <pre><code>str = str.replace(/(['"&amp;:;])/g, "\\$1");
  </code></pre>
  
  <p>Thanks again Sniffer for the quick response!</p>