我正在编写由其他人实现的代码,如下所示
+(BOOL)emailValidate:(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];
}
+(BOOL) IDValidate:(NSString *)ID {
NSString *regexString = @"[ A-Z0-9a-z_+-]{1,20}";
NSPredicate *regex = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regexString];
return [regex evaluateWithObject:ID];
}
我想在 ID 和电子邮件中使用空格“”和逗号“,”,我搜索了很多如何更改 predicateFormat 但找不到答案。