I am using the following code to check the validation of my email which is entered in the uitextfield. But it is returning true when I enter [email protected] it is not returning false.
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:email];
Anyone can suggest me ?
Don't exclude the domain m.com.com
, as it's a possible subdomain of com.com
(wich maybe looks strange, but is a valid - and btw. real - domain).
If you still want to exclude all subdomains (saying: only allow one .
after @
) you would exclude email addresses like:
So, you maybe don't want to exclude them.