I am Trying to validate email address field using below regex
+ (BOOL) isValidEmail:(NSString *)email
{
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];
}
But its getting failed for validating below cases.
i) test@-gmail.com
ii) test..test@gmail.com
iii) .test@gmail.com
iv) test.@gmail.com
Please suggest me what modification do I need for considering these cases.