IOS verification of the phone number of the regular expression _ios

Source: Internet
Author: User

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.

Related Article

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.