Skip to content

Instantly share code, notes, and snippets.

@nileshpunjabi
Forked from sag333ar/validateAnEmail.m
Created August 28, 2014 10:26
Show Gist options
  • Save nileshpunjabi/b0a0dff2b858b70f8ba1 to your computer and use it in GitHub Desktop.
Save nileshpunjabi/b0a0dff2b858b70f8ba1 to your computer and use it in GitHub Desktop.
- (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