Skip to content

Instantly share code, notes, and snippets.

@sag333ar
Created December 3, 2013 12:43
Show Gist options
  • Save sag333ar/7768572 to your computer and use it in GitHub Desktop.
Save sag333ar/7768572 to your computer and use it in GitHub Desktop.
Validate an email ID with NSPredicate
- (BOOL) validateEmail: (NSString *) candidate {
NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
return [emailTest evaluateWithObject:candidate];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment