//正則表達(dá)式 驗(yàn)證是否是手機(jī)號(hào)
86 BOOL isMobileNum=[self isMobileNumber:p8.productName];
87 if(isMobileNum)
88 NSLog(@"是真確的手機(jī)號(hào):%@",p8.productName);
89
90 }
91
92
93 - (BOOL)isMobileNumber:(NSString )mobileNum
94 {
95 /*
96 * 手機(jī)號(hào)碼
97 * 移動(dòng):134[0-8],135,136,137,138,139,150,151,157,158,159,182,187,188
98 * 聯(lián)通: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 * 中國(guó)移動(dòng):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 * 中國(guó)聯(lián)通: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 * 中國(guó)電信: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 * 大陸地區(qū)固話及小靈通
119 26 * 區(qū)號(hào):010,020,021,022,023,024,025,027,028,029
120 27 * 號(hào)碼:七位或八位
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(@"中國(guó)移動(dòng)");
136 } else if([regextestct evaluateWithObject:mobileNum] == YES) {
137 NSLog(@"聯(lián)通");
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