Discuz!论坛插件设置手机号码最新正则虚拟号段180等正则写法
Discuz!论坛插件设置手机号码最新正则虚拟号段180、190、等正则写法:
- /**
- * 手机号码格式验证
- */
- + (BOOL)isTelphoneNumber:(NSString *)telNum {
- BOOL ret = NO;
- telNum = [telNum stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
- if ([telNum length] != 11) {
- ret = NO;
- }
-
- /**
- * 规则 -- 更新日期 2017-03-30
- * 手机号码: 13[0-9], 14[5,7,9], 15[0, 1, 2, 3, 5, 6, 7, 8, 9], 17[0, 1, 6, 7, 8], 18[0-9]
- * 移动号段: 134,135,136,137,138,139,147,150,151,152,157,158,159,170,178,182,183,184,187,188
- * 联通号段: 130,131,132,145,155,156,170,171,175,176,185,186
- * 电信号段: 133,149,153,170,173,177,180,181,189
- *
- * [数据卡]: 14号段以前为上网卡专属号段,如中国联通的是145,中国移动的是147,中国电信的是149等等。
- * [虚拟运营商]: 170[1700/1701/1702(电信)、1703/1705/1706(移动)、1704/1707/1708/1709(联通)]、171(联通)
- * [卫星通信]: 1349
- */
-
- /**
- * 中国移动:China Mobile
- 中国移动获得了198(0-9)
- * 134,135,136,137,138,139,147(数据卡),150,151,152,157,158,159,170[5],178,182,183,184,187,188
- */
- NSString *CM_NUM = @"^((198[0-9])|(13[4-9])|(147)|(15[0-2,7-9])|(17[8])|(18[2-4,7-8]))\\d{8}|(170[5-6])\\d{7}[ DISCUZ_CODE_0 ]quot;;
-
- /**
- * 中国联通:China Unicom
- 中国联通获得了166(0-9)号段(公众移动通信网网号)
- * 130,131,132,145(数据卡),155,156,170[4,7-9],171,175,176,185,186
- */
- NSString *CU_NUM = @"^((166[0-9])|(13[0-2])|(145)|(15[5-6])|(17[156])|(18[5,6]))\\d{8}|(170[4,7-9])\\d{7}[ DISCUZ_CODE_0 ]quot;;
-
- /**
- * 中国电信:China Telecom
- * 133,149(数据卡),153,170[0-2],173,177,180,181,189
- 中国电信获得了199(0-9)号段(公众移动通信网网号)
- */
- NSString *CT_NUM = @"^((199[0-9])|(133)|(149)|(153)|(17[3,7])|(18[0,1,9]))\\d{8}|(170[0-3])\\d{7}[ DISCUZ_CODE_0 ]quot;;
-
- NSPredicate *pred_CM = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",CM_NUM];
- NSPredicate *pred_CU = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",CU_NUM];
- NSPredicate *pred_CT = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",CT_NUM];
- BOOL isMatch_CM = [pred_CM evaluateWithObject:telNum];
- BOOL isMatch_CU = [pred_CU evaluateWithObject:telNum];
- BOOL isMatch_CT = [pred_CT evaluateWithObject:telNum];
- if (isMatch_CM || isMatch_CT || isMatch_CU) {
- ret = YES;
- }
- return ret;
- }