title: Javascript onchange regex / character
body: <p>I have an onchange within an input. However the regex pattern is not getting created correctly. </p>
  
  <pre><code>jQuery(this).attr("onchange", " 
  var cat = jQuery('.coverage'); 
  var dog = 0; 
  for(var i = 0; i &lt; cat.length; i++){ 
   if(cat[i].value){ 
    dog = parseInt(cat[i].value.replace(/\,/g,''), 10) + dog;
   } 
  } 
  var pat = new RegExp('\\B(?=(\d{3})+(?!\d))' , 'g');   
  jQuery('#total').val(dog); ");
  </code></pre>
  
  <p>the pattern instead of being: </p>
  
  <pre><code>/\B(?=(d{3})+(?!d))/g
  </code></pre>
  
  <p>come out:</p>
  
  <pre><code>/B(?=(d{3})+(?!d))/g 
  </code></pre>
  
  <p>Note the onchange attr in this context is necessary sadly... </p>