+(BOOL) isValidateMobile:(NSString *)mobile { //手机号以13, 15,18开头,八个 d 数字字符 NSString *phoneRegex = @"^((13[0-9])|(15[^4,\D])|(18[0,0-9]))\d{8}$"; NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex]; // NSLog(@"phoneTest is %@",phoneTest); return [phoneTest evaluateWithObject:mobile]; }
- (BOOL)isPhoneNumber { NSString *Regex = @"(13[0-9]|14[57]|15[0-9]|18[0235-9])\d{8}"; NSPredicate *mobileTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", Regex]; return [mobileTest evaluateWithObject:self]; }
// 商品条码标准位13位 - (BOOL)checkBarcode:(NSString *)_text { NSString *regex = @"^\d{13}$"; NSPredicate *test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex]; return [test evaluateWithObject:_text]; }