Cell phone number regular judgment

Source: Internet
Author: User

//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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.