title: JavaScript: Invalid quantifier in regex
body: <p>The regex is constructed on the fly, but I've output it to firebug:</p>
  
  <pre><code>(.{1,38})(+|$\n?)
  </code></pre>
  
  <p>the error is</p>
  
  <pre><code>invalid quantifier +|$\n?)
  </code></pre>
  
  <p>I'm not sure where to start.</p>
  
  <p>The actual code is:</p>
  
  <pre><code>var re = top.RegExp;
  var regex = new re("(.{1," + len + "})(+|$\\n?)", "gm");
  </code></pre>
  
  <p><strong>UPDATE:</strong>
  Per Bennor McCarthy's instructions, I changed the code to this:</p>
  
  <pre><code> var regex = new re("(.{1," + len + "})(\+|\$\\n?)", "gm");
  </code></pre>
  
  <p>Firebug still tells me this:</p>
  
  <pre><code>invalid quantifier +|$\n?)
  [Break on this error] var regex = new re("(.{1," + len + "})(\+|\$\\n?)", "gm"); 
  </code></pre>
  
  <p><strong>ANOTHER UPDATE</strong>
  Looks Like I had to double slash it and this solved the problem!</p>
  
  <h2>final code</h2>
  
  <pre><code>var regex = new re("(.{1," + len + "})(\\+|\\$\\n?)", "gm");
  </code></pre>