ios正则匹配用户密码6-20位数字和字母组合
2016-09-12 本文已影响1312人
透支未来
- (BOOL)checkPassword:(NSString *) password
{
NSString *pattern = @"^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z0-9]{6,20}";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES%@",pattern];
BOOL isMatch = [pred evaluateWithObject:password];
return isMatch;
}