title: Regex for Email validation in objective c
body: <p>I want to validate email id :</p>
  
  <p>abc.pqr@companyname.com :-- Valid</p>
  
  <p>abc.pqr@xyz.companyname.com : invalid</p>
  
  <p>As per my knowledge multiple dots are not allowed after "@" in email id.
  Please advice how can i detect the more the one dots after @ and and check the validation.</p>
  
  <p>I am using below regex for email validation.
  both are working fine.
  But not able to check multiple dots after @ symbols.</p>
  
  <pre><code> NSString *emailRegex =
      @"(?:[a-z0-9!#$%\\&amp;'*+/=?\\^_`{|}~-]+(?:\\.[a-z0-9!#$%\\&amp;'*+/=?\\^_`{|}"
      @"~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\"
      @"x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-"
      @"z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5"
      @"]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-"
      @"9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21"
      @"-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])";
      NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES[c] %@", emailRegex];
  
      return [emailTest evaluateWithObject:email];
  </code></pre>
  
  <p>I also tried this : </p>
  
  <pre><code>NSString *regex1 = @"\\A[a-z0-9]+([-._][a-z0-9]+)*@([a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,4}\\z";
      NSString *regex2 = @"^(?=.{1,64}@.{4,64}$)(?=.{6,100}$).*";
      NSPredicate *test1 = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex1];
      NSPredicate *test2 = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex2];
      return [test1 evaluateWithObject:email] &amp;&amp; [test2 evaluateWithObject:email];
  </code></pre>