title: Javascript: Regex to escape parentheses and spaces
body: <p>Looking to backslash escape parentheses and spaces in a javascript string.</p>
  
  <p>I have a string: <code>(some string)</code>, and I need it to be <code>\(some\ string\)</code></p>
  
  <p>Right now, I'm doing it like this:</p>
  
  <pre><code>x = '(some string)'
  x.replace('(','\\(')
  x.replace(')','\\)')
  x.replace(' ','\\ ')
  </code></pre>
  
  <p>That works, but it's ugly. Is there a cleaner way to go about it?</p>