//判断是否是合法的电话号码
+ (BOOL)isChinaMobile:(NSString *)phoneNum{
BOOL isChinaMobile = NO;
NSString *CM = @"(^1(3[4-9]|4[7]|5[0-27-9]|7[8]|8[2-478])\\d{8}$)|(^1705\\d{7}$)";
NSPredicate *regextestcm = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CM];
if([regextestcm evaluateWithObject:phoneNum] == YES){
isChinaMobile = YES;
// NSLog(@"中国移动");
}
NSString *CU = @"(^1(3[0-2]|4[5]|5[56]|7[6]|8[56])\\d{8}$)|(^1709\\d{7}$)";
NSPredicate *regextestcu = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CU];
if([regextestcu evaluateWithObject:phoneNum] == YES){
isChinaMobile = YES;
// NSLog(@"中国联通");
}
NSString *CT = @"(^1(33|53|77|8[019])\\d{8}$)|(^1700\\d{7}$)";
NSPredicate *regextestct = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CT];
if([regextestct evaluateWithObject:phoneNum] == YES){
isChinaMobile = YES;
// NSLog(@"中国电信");
}
return isChinaMobile;
}
//判断是否是合法的邮箱
+ (BOOL)validateEmail:(NSString *)email{
NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
return [emailTest evaluateWithObject:email];
}