This example for you to share the iOS verified mobile phone number of code snippets for your reference, the specific content as follows
Determine if the phone number format is correct + (BOOL) Valimobile: (NSString *) Mobile {mobile = Mobile stringbyreplacingoccurrencesofstring:@ "" Withst
ring:@ ""];
if (Mobile.length!=) {return NO; }else{/** * Mobile number section 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 section Regular Expression * * * nsstring *cu_num = @ "^ ((13[0-2)) | ( 145) | (15[5-6]) | (176) | (18[5,6]) \\d{8}|
(1709) \\d{7}$ "; /** * Electrical Signal Section Regular expression * * * nsstring *ct_num = @ "^ ((133) | ( 153) | (177) | (18[0,1,9])
\\d{8}$ ";
Nspredicate *pred1 = [nspredicatepredicatewithformat:@ "SELF matches%@", Cm_num];
BOOL isMatch1 = [pred1 evaluatewithobject:mobile];
Nspredicate *pred2 = [nspredicatepredicatewithformat:@ "SELF matches%@", Cu_num];
BOOL ISMATCH2 = [Pred2 evaluatewithobject:mobile];
Nspredicate *pred3 = [nspredicatepredicatewithformat:@ "SELF matches%@", Ct_num];
BOOL ISMATCH3 = [Pred3 evaluatewithobject:mobile]; if (IsMatch1 | | isMatch2||
ISMATCH3) {return YES;
}else{return NO;
}
}
}
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.