title: Getting "error: invalid regular expression"
body: <p>So I have this code where I'd like to replace all single backslashes with 2 backslashes, for example: \ ---> \\ I tried to do this by the following code:</p>
  
  <pre><code>string = string.replace(new RegExp("\\", "g"), "\\\\");
  </code></pre>
  
  <p>But apparently this doesn't work because I get the following error:</p>
  
  <blockquote>
    <p>Uncaught SyntaxError: Invalid regular expression: //: \ at end of pattern</p>
  </blockquote>
  
  <p>Any idea why?</p>