Skip to content

Instantly share code, notes, and snippets.

@helloworld116
Created March 11, 2013 05:13
Show Gist options
  • Save helloworld116/5132033 to your computer and use it in GitHub Desktop.
Save helloworld116/5132033 to your computer and use it in GitHub Desktop.
regex:email
//objective-c使用正则表达式验证邮箱
+ (BOOL)isEmailAddress:(NSString*)email {
NSString *emailRegex = @"^\\w+((\\-\\w+)|(\\.\\w+))*@[A-Za-z0-9]+((\\.|\\-)[A-Za-z0-9]+)*.[A-Za-z0-9]+$";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
return [emailTest evaluateWithObject:email];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment