title: Javascript str_replace use "plus" and "minus" characters in regex
body: <p>I need to replace two different characters in a string all instances so i found this answer</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
     var filter_out = eval("/1|3/ig");
     var myvar = "1 2 3";
     alert(myvar.replace(filter_out, "-"));
  &lt;/script&gt;
  
  // - 2 -
  </code></pre>
  
  <p>It works, however this one does not:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
     var filter_out = eval("/\+|\-/ig");
     var myvar="+ 2 -";
     alert(myvar.replace(filter_out, "-"));
  &lt;/script&gt;
  
  //SyntaxError: invalid quantifier: /+|-/ig
  </code></pre>
  
  <p>Never mind i fond that it works if i use </p>
  
  <pre><code>var filter_out = eval("/\\+|\\-/ig");
  </code></pre>
  
  <p>can someone explain why it has to be double \?
  Also i know "g" stands for global - all occurances, what "i" stands for?</p>