I used the Mimit solution, but modified emailRegex to use longer names such as a museum. Therefore, the last braces now say that {2, 6} is not {2, 4}. And I tested it with a longer name, and it works. Thanks to Mimit for the easy solution.
-(BOOL) validateEmail: (NSString *) candidate { NSString *emailRegex = @"[A-Z0-9a-z._%+-] +@ [A-Za-z0-9.-]+\\.[A-Za-z]{2,6}"; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
timv
source share