iOS 正则表达式入门
2016-07-28 本文已影响5人
山杨
例:
// 请输入首位为字母,6-20位数字或字母组合的账号
+ (BOOL)isVaildAccount:(NSString *)account {
NSString *format = @"^([A-Za-z])[A-Za-z0-9]{5,19}$";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"Self matches %@", format];
BOOL isVaildAccount = [predicate evaluateWithObject:account];
return isVaildAccount;
}