IOS determines whether the email address, mobile phone number, and license plate number are valid (regular expression)

Source: Internet
Author: User
/* Email verification modified by helensong */-(bool) isvalidateemail :( nsstring *) email {nsstring * emailregex = @ "[A-Z0-9a-z. _ % +-] + @ [A-Za-z0-9. -] + \\. [A-Za-Z] {2, 4} "; nspredicate * emailtest = [nspredicate predicatewithformat: @" Self matches % @ ", emailregex]; return [emailtest email];} /* Verify the mobile phone number modified by helensong */-(bool) isvalidatemobile :( nsstring *) mobile {// the mobile phone number starts with 13, 15, and 18, eight \ D numeric characters nsstring * phoneregex = @ "^ (13 [0-9]) | (15 [^ 4, \ D]) | (18 [0, 0-9]) \ D {8} $ "; nspredicate * phonetest = [nspredicate predicatewithformat: @" Self matches % @ ", phoneregex]; // nslog (@ "phonetest is % @", phonetest); return [phonetest evaluatewithobject: Mobile];}/* plate number verification modified by helensong */bool validatecarno (nsstring * carno) {nsstring * carregex = @ "^ [A-Za-Z] {1} [A-Za-z_0-9] {5} $"; nspredicate * cartest = [nspredicate predicatewithformat: @ "Self matches % @", carregex]; nslog (@ "cartest is % @", cartest); return [cartest evaluatewithobject: carno];}

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.