判断手机号码

// 中国移动:China Mobile

#define  ChinaMobile @"^13[4-9]\\d{8}$|^15[012789]\\d{8}$|^18[23478]\\d{8}$|^147\\d{8}$"


// 中国联通:China Unicom

#define ChinaUnicom @"^1(3[0-2]|5[256]|8[56])\\d{8}$"


// 中国电信:China Telecom

#define ChinaTelecom @"^1((33|53|8[09])[0-9]|349)\\d{7}$"


// 手机号码

#define mobileNumber  @"^1(3[0-9]|5[0-35-9]|8[025-9])\\d{8}$"


//
判断手机号码 + (BOOL)validateMobile:(NSString *)mobileNum { NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", mobileNumber]; NSPredicate *regextestcm = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", ChinaMobile]; NSPredicate *regextestcu = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", ChinaUnicom]; NSPredicate *regextestct = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", ChinaTelecom]; if (([regextestmobile evaluateWithObject:mobileNum] == YES) || ([regextestcm evaluateWithObject:mobileNum] == YES) || ([regextestct evaluateWithObject:mobileNum] == YES) || ([regextestcu evaluateWithObject:mobileNum] == YES)) { return YES; } else { return NO; } }

 

posted @ 2014-12-19 12:18  菜鸟程序猿  阅读(632)  评论(0编辑  收藏  举报