Mobile phone number verification (regular)

Source: Internet
Author: User

1, mobile phone number has become the recommended choice of various types of app accounts, but this will also involve the verification of mobile phone numbers,

As a result of the addition of the 170 segment this year, many of the current categories do not provide this, so it can only be modified

Not much to say direct sticker code:

/** * Mobile phone Number Verification * * @param mobile * * @return*/+ (BOOL) Validatemobile: (NSString *) mobile{//phone number starts with 13, 15, 18, eight \d numeric charactersNSString *phoneregex =@"^ ((13[0-9)) | ( 15[^4,\\D]) | (18[0,0-9])) \\d{8}$"; Nspredicate*phonetest = [Nspredicate predicatewithformat:@"Self MATCHES%@", Phoneregex]; BOOL result=[Phonetest Evaluatewithobject:mobile]; NSLog (@"result =%d", result); returnresult;}
^ ((13[0-9]) | (15[^4,\\d]) | (18[0,0-9])) \\D{8}  key code, so just add a 170 verification to it.

/** * Mobile phone Number Verification * * @param mobile * * @return*/+ (BOOL) Validatemobile: (NSString *) mobile{//phone number starts with 13, 15, 18, eight \d numeric charactersNSString *phoneregex =@"^ ((13[0-9)) | ( 15[^4,\\D]) | (18[0,0-9]) | (170)) \\d{8}$"; Nspredicate*phonetest = [Nspredicate predicatewithformat:@"Self MATCHES%@", Phoneregex]; BOOL result=[Phonetest Evaluatewithobject:mobile]; NSLog (@"result =%d", result); returnresult;}

Mobile phone number verification (regular)

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.