title: Regex Error in Chome using Javascript
body: <p>I have the following regex <code>/^[a-zA-Z0-9-\_.]+@[a-zA-Z0-9-\_.]+\.[a-zA-Z0-9.]{2,5}$/</code> and when I test the regex in an online tester, it works just fine, but when I try and use it on Chrome, I get an error:</p>
  
  <blockquote>
    <p>Pattern attribute value ^[a-zA-Z0-9-_.]+@[a-zA-Z0-9-_.]+.[a-zA-Z0-9.]{2,5}$ is not a valid regular expression: Uncaught SyntaxError: Invalid regular expression: /^[a-zA-Z0-9-_.]+@[a-zA-Z0-9-_.]+.[a-zA-Z0-9.]{2,5}$/: Invalid escape</p>
  </blockquote>
  
  <p>UPDATE:</p>
  
  <p>I also get the error in Firefox:</p>
  
  <blockquote>
    <p>Unable to check  because the pattern is not a valid regexp: invalid identity escape in regular expression</p>
  </blockquote>
  
  <p>Here is the javascript code that is being used:</p>
  
  <pre><code>jQuery( "#contact_submit" ).submit(function( event ) {
      event.preventDefault();
      //Loader Image
     jQuery("#loader").show();
      var templateUrl = object_name.templateUrl;
      //Template Path
      jQuery("#loader").html("&lt;img src="+templateUrl+"/aj-loader.gif alt='' width='35'&gt;");
  
  
      var name = jQuery('#name_vc').val();
      var lname = jQuery('#name_lvc').val();
      var email = jQuery('#email_vc').val();
      var subject = jQuery('#subject_vc').val();
      var message = jQuery('#message_vc').val();    
      var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
      var errormsg = "";
  
      if(name == ""){
          errormsg = "&lt;p&gt;&lt;font color='red'&gt;&lt;h5 class = 'form_name_field'&gt;Please Enter Name&lt;/h5&gt;&lt;/font&gt;&lt;/p&gt;";
      }
      if(email == ""){
          errormsg += "&lt;p&gt;&lt;font color='red'&gt;&lt;h5 class = 'form_name_field'&gt;Please Enter Email&lt;/h5&gt;&lt;/font&gt;&lt;/p&gt;";
      } else if (!filter.test(email)) {
          errormsg += "&lt;p&gt;&lt;font color='red'&gt;&lt;h5 class = 'form_name_field'&gt;Please Provide A Valid Email Address&lt;/h5&gt;&lt;/font&gt;&lt;/p&gt;";
      }
      if(subject == ""){
          errormsg += "&lt;p&gt;&lt;font color='red'&gt;&lt;h5 class = 'form_name_field'&gt;Please Enter Subject&lt;/h5&gt;&lt;/font&gt;&lt;/p&gt;";
      }
      if(message == ""){
          errormsg += "&lt;p&gt;&lt;font color='red'&gt;&lt;h5 class = 'form_name_field'&gt;Please Enter Message&lt;/h5&gt;&lt;/font&gt;&lt;/p&gt;";
      } 
  
      if(errormsg != ""){
          jQuery("#loader").html(errormsg);
          return false;
      }
  
      jQuery.ajax({
          url: ajaxurl,
          data: {
              'action':'courses_ajax_request',
              'type':'display_contact',
  
              'name': jQuery('#name_vc').val(),
              'lname': jQuery('#name_lvc').val(),
              'email': jQuery('#email_vc').val(),
              'subject': jQuery('#subject_vc').val(),
              'message': jQuery('#message_vc').val(),
              'email_to': jQuery('#email_to').val()
          },
          success:function(data) {
              jQuery("#loader").html(data).delay( 5000 ).hide('slow');
              jQuery('#name_vc').val(""),
              jQuery('#name_lvc').val(""),
              jQuery('#email_vc').val(""),
              jQuery('#subject_vc').val(""),
              jQuery('#message_vc').val("")
          },
          error: function(errorThrown){
              console.log(errorThrown);
          }
      });
  
  
  });
  </code></pre>
  
  <p>Can someone tell me what is going on and how I can fix it? </p>