title: Regex failing again and again in javascript
body: <p>I have a regex for first name and last name. Even when I give proper inputs according to the regex it fails. I tried changing different regexs but still it fails. For test I even used the only numbers regex but still it failed. Below is the code which I am using.</p>
  
  <pre><code>&lt;form id="register_form" action="{{url('/register')}}" method="post" accept-charset="UTF-8"&gt;
     &lt;div class="col-sm-6"&gt;
        &lt;div class="form-group"&gt;
              &lt;label for="name"&gt;Name&lt;/label&gt;
              &lt;input type="text" id="first_name" class="form-control" placeholder="Enter Name" name="first_name"&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/jquery.validate.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/additional-methods.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
      $.validator.addMethod(
          "regex",
          function(value, element, regexp) {
              var re = new RegExp(regexp);
              return this.optional(element) || re.test(value);
          },
          "Number Not valid."
      );
  
      $("#register_form").validate({
          rules: {
              first_name: {required:true, minlength:2, regex:"^[a-zA-Z]+((\\s|\\-)[a-zA-Z]+)?$"},
          },
          messages:   {
              first_name:{required:'First name is required',minlength:'First name should contain atleast two alphabets',regex:'Only alphabets allowed and it should not start with space.'},
          }
      );
  &lt;/script&gt;
  </code></pre>
  
  <p>My input which fails is Raj Shah, this should work perfectly fine. I checked for duplicate input id but there is none. I checked the regex on online tester there it works fine. </p>