title: iOS email address validation
body: <p>I've got a form and what I'm trying to do is validate email addresses before they're inserted into my database. I've read multiple posts on this already and none of them have solved my problem.</p>
  
  <p>This is the code that I have so far. </p>
  
  <pre><code>-(BOOL) validEmail:(NSString*) emailString {
      NSString *regExPattern = @"[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";  
  
      NSRegularExpression *regEx = [[NSRegularExpression alloc] initWithPattern:regExPattern options:NSRegularExpressionCaseInsensitive error:nil];
  
      NSUInteger regExMatches = [regEx numberOfMatchesInString:emailString options:0 range:NSMakeRange(0, [emailString length])];
  
      if (regExMatches == 0) {
          return NO;
      } else
          return YES;
  }
  </code></pre>
  
  <p>The regex matches nearly every email address, but when addresses are in the format abc,def@gmail.com, it fails to catch it as an invalid address. It won't pick up the comma. </p>
  
  <p>Anyone have any ideas where i'm going wrong? Thanks</p>