Verify that the phone number/mailbox is legal

Source: Internet
Author: User

determine if the phone number is legal

+ (BOOL) Ischinamobile: (nsstring *) phonenum{

BOOL ischinamobile = NO;

nsstring *cm = @ "(^1 (3[4-9]|4[7]|5[0-27-9]|7[8]|8[2-478]) \\d{8}$) | ( ^1705\\d{7}$) ";

nspredicate *regextestcm = [nspredicate predicatewithformat:@ "self MATCHES%@", CM];

if([regextestcm evaluatewithobject:p honenum] = = YES) {

Ischinamobile = YES;

// NSLog (@ " China Mobile ");

}

nsstring *cu = @ "(^1 (3[0-2]|4[5]|5[56]|7[6]|8[56]) \\d{8}$) | ( ^1709\\d{7}$) ";

nspredicate *regextestcu = [nspredicate predicatewithformat:@ "self MATCHES%@", CU];

if([Regextestcu evaluatewithobject:p honenum] = = YES) {

Ischinamobile = YES;

// NSLog (@ " China Unicom ");

}

nsstring *ct = @ "(^1 (33|53|77|8[019]) \\d{8}$) | ( ^1700\\d{7}$) ";

nspredicate *regextestct = [nspredicate predicatewithformat:@ "Self MATCHES%@" , CT];

if([regextestct evaluatewithobject:p honenum] = = YES) {

Ischinamobile = YES;

// NSLog (@ " China Telecom ");

}

return ischinamobile;

}

determine if the mailbox is legitimate

+ (BOOL) Validateemail: (nsstring *) email{

nsstring *emailregex = @ "[A-z0-9a-z._%+-][email protected][a-za-z0-9.-]+\\.[ a-za-z]{2,4} ";

nspredicate *emailtest = [nspredicate predicatewithformat:@ "self MATCHES%@" , Emailregex];

return [emailtest evaluatewithobject: email];

}

Verify that the phone number/mailbox is legal

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.