// 商品条码标准位13位
+(BOOL)checkBarcode:(NSString *)_text
{
NSString *regex = @"^\\d{13}$";
NSPredicate *test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
return [test evaluateWithObject:_text];
}
//一到四位小数的正实数(价格)
+(BOOL)checkMoney:(NSString *)_text
{
NSString *regex = @"^[0-9]+(.[0-9]{1,4})?$";
NSPredicate *Test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
return [Test evaluateWithObject:_text];
}
//所有的英文字母(A-z)
+(BOOL)checkManufacturers:(NSString *)_text
{
NSString *regex1 = @"^[A-Za-z]+$";
NSPredicate *Test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex1];
return [Test evaluateWithObject:_text];
}
//汉字
+(BOOL)checkBrand:(NSString *)_text
{
NSString *regex1 = @"^[\u4e00-\u9fa5]{0,}$";
NSPredicate *Test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex1];
return [Test evaluateWithObject:_text];
}
//数字(0-9)
+(BOOL)checkNumber:(NSString *)_text
{
NSString *regex1 = @"^[0-9]*$";
NSPredicate *Test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex1];
return [Test evaluateWithObject:_text];
}
//手机号和电话号(11位和12位)
+(BOOL)checkPhoneNum:(NSString *)_text
{
NSString *regex1 = @"^(\\d{3.4}-)\\d{7,8}$";
NSPredicate *Test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex1];
return [Test evaluateWithObject:_text];
}
//用户名和密码(6-16位的字母数字和下划线组合)
+(BOOL)checkUserAndPassword:(NSString *)_text
{
NSString *regex1 = @"^[a-zA-Z]\\w{5,15}$";
NSPredicate *Test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex1];
return [Test evaluateWithObject:_text];
}