//是否是n位纯数字
-(BOOL)validateOfLength:(NSInteger)length WithString:(NSString *)str{
/*
@"^\\d{6}$"
(6个连续数字,以数字开头,以数字结尾)
*/
NSString *pwdRegex = [NSString stringWithFormat:@"^\\d{\%ld}$",(long)length];
NSPredicate *pwdTest = [NSPredicate predicateWithFormat:@"SELF MATCHES \%@",pwdRegex];
BOOL isMatch= [pwdTest evaluateWithObject:str];
if (!isMatch) {
return NO;
}
return isMatch;
}