//determine if the phone number format is correct+ (BOOL) Valimobile: (NSString *) mobile{Mobile= [Mobile stringbyreplacingoccurrencesofstring:@" "Withstring:@""]; if(Mobile.length! = One) { returnNO; }Else{ /** Mobile number segment Regular Expression*/NSString*cm_num =@"^ ((13[4-9)) | ( 147) | (15[0-2,7-9]) | (178) | (18[2-4,7-8])) \\d{8}| (1705) \\d{7}$"; /** * Unicom number Regular expression*/NSString*cu_num =@"^ ((13[0-2)) | ( 145) | (15[5-6]) | (176) | (18[5,6])) \\d{8}| (1709) \\d{7}$"; /** * Signal segment Regular expression*/NSString*ct_num =@"^ ((133) | ( 153) | (177) | (18[0,1,9])) \\d{8}$"; Nspredicate*pred1 = [Nspredicate predicatewithformat:@"Self MATCHES%@", Cm_num]; BOOL IsMatch1=[pred1 Evaluatewithobject:mobile]; Nspredicate*pred2 = [Nspredicate predicatewithformat:@"Self MATCHES%@", Cu_num]; BOOL ISMATCH2=[Pred2 Evaluatewithobject:mobile]; Nspredicate*PRED3 = [Nspredicate predicatewithformat:@"Self MATCHES%@", Ct_num]; BOOL IsMatch3=[Pred3 Evaluatewithobject:mobile]; if(IsMatch1 | | isMatch2 | |IsMatch3) { returnYES; }Else{ returnNO; } }}
Cell phone number regular judgment