1、简单检测身份证是否合法
-(BOOL)checkIDCard:(NSString *)idCardStr{ NSString *regex=@"^(\\d{15}$|^\\d{18}$|^\\d{17}(\\d|X|x))$"; NSPredicate *predicate=[NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex]; if (![predicate evaluateWithObject:idCardStr]) { return NO; } else{ return YES; }}