1.必须包含英文字母的大写、小写、数字,可且仅支持符号!_@-#.*%?
正则表达
NSString *emailRegex = @"^(?![^a-z]+$)(?![^A-Z]+$)(?!\\D+$)[!_@\\-#.*%?\\w]{8,15}$";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
// return ![emailTest evaluateWithObject:self];
if ([emailTest evaluateWithObject:self]) {
return YES;
}
2.不可包含2位以上相同的、顺序、逆序的数字、小写英文字母或大写英文字母(错误举例:111、012、321、abc、CBA、aaa)
正则表达
NSString *emailRegex = @"^(?!.*([!-~])\\1{2,})(?!.*(?:012|210|123|321|234|432|345|543|456|654|567|765|678|876|789|987))(?!.*(?:ABC|CBA|BCD|DCB|CDE|EDC|DEF|FED|EFG|GFE|FGH|HGF|GHI|IHG|HIJ|JIH|IJK|KJI|JKL|LKJ|KLM|MLK|LMN|NML|MNO|ONM|NOP|PON|OPQ|QPO|PQR|RQP|QRS|SRQ|RST|TSR|STU|UTS|TUV|VUT|UVW|WVU|VWX|XWV|WXY|YXW|XYZ|ZYX|abc|cba|bcd|dcb|cde|edc|def|fed|efg|gfe|fgh|hgf|ghi|ihg|hij|jih|ijk|kji|jkl|lkj|klm|mlk|lmn|nml|mno|onm|nop|pon|opq|qpo|pqr|rqp|qrs|srq|rst|tsr|stu|uts|tuv|vut|uvw|wvu|vwx|xwv|wxy|yxw|xyz|zyx)).+$";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
// return ![emailTest evaluateWithObject:self];
if ([emailTest evaluateWithObject:self]) {
return YES;
}
return NO;