//正则表达式 验证是否是手机号
86 BOOL isMobileNum=[self isMobileNumber:p8.productName];
87 if(isMobileNum)
88 NSLog(@"是真确的手机号:%@",p8.productName);
89
90 }
91
92
93 - (BOOL)isMobileNumber:(NSString )mobileNum
94 {
95 /*
96 * 手机号码
97 * 移动:134[0-8],135,136,137,138,139,150,151,157,158,159,182,187,188
98 * 联通:130,131,132,152,155,156,185,186
99 * 电信:133,1349,153,180,189
100 /
101 NSString * MOBILE = @"^1(3[0-9]|5[0-35-9]|8[025-9])\d{8}$";
102 /*
103 10 * 中国移动:China Mobile
104 11 * 134[0-8],135,136,137,138,139,150,151,157,158,159,182,187,188
105 12 /
106 NSString * CM = @"^1(34[0-8]|(3[5-9]|5[017-9]|8[278])\d)\d{7}$";
107 /*
108 15 * 中国联通:China Unicom
109 16 * 130,131,132,152,155,156,185,186
110 17 /
111 NSString * CU = @"^1(3[0-2]|5[256]|8[56])\d{8}$";
112 /*
113 20 * 中国电信:China Telecom
114 21 * 133,1349,153,180,189
115 22 /
116 NSString * CT = @"^1((33|53|8[09])[0-9]|349)\d{7}$";
117 /*
118 25 * 大陆地区固话及小灵通
119 26 * 区号:010,020,021,022,023,024,025,027,028,029
120 27 * 号码:七位或八位
121 28 */
122 // NSString * PHS = @"^0(10|2[0-5789]|\d{3})\d{7,8}$";
123
124 NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", MOBILE];
125 NSPredicate *regextestcm = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CM];
126 NSPredicate *regextestcu = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CU];
127 NSPredicate *regextestct = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CT];
128
129 if (([regextestmobile evaluateWithObject:mobileNum] == YES)
130 || ([regextestcm evaluateWithObject:mobileNum] == YES)
131 || ([regextestct evaluateWithObject:mobileNum] == YES)
132 || ([regextestcu evaluateWithObject:mobileNum] == YES))
133 {
134 if([regextestcm evaluateWithObject:mobileNum] == YES) {
135 NSLog(@"中国移动");
136 } else if([regextestct evaluateWithObject:mobileNum] == YES) {
137 NSLog(@"联通");
138 } else if ([regextestcu evaluateWithObject:mobileNum] == YES) {
139 NSLog(@"电信");
140 } else {
141 NSLog(@"Unknow");
142 }
143
144 return YES;
145 }
146 else
147 {
148 return NO;
149 }
150 }
151 @end