iOS uses common regular expressions to verify password ID phone number

Source: Internet
Author: User

#pragma regular match phone number + (BOOL) Checktelnumber: (NSString *) telnumber{nsstring *pattern = @^1+[3578]+\d{9};    Nspredicate *pred = [nspredicate predicatewithformat: @SELF MATCHES%@, pattern];    BOOL IsMatch = [pred evaluatewithobject:telnumber];  return isMatch;} #pragma regular match user password 6-18 digits and letter combination + (BOOL) Checkpassword: (NSString *) password{nsstring *pattern = @^ (?! [0-9]+$) (?!    [a-za-z]+$] [a-za-z0-9]{6,18};    Nspredicate *pred = [nspredicate predicatewithformat: @SELF MATCHES%@, pattern];    BOOL IsMatch = [pred Evaluatewithobject:password];     return isMatch;    } #pragma match user name, 20-bit Chinese or English + (BOOL) Checkusername: (NSString *) username{nsstring *pattern = @^[a-za-z one-calls]{1,20};    Nspredicate *pred = [nspredicate predicatewithformat: @SELF MATCHES%@, pattern];    BOOL IsMatch = [pred evaluatewithobject:username];     return isMatch; } #pragma regular match user ID number 15 or 18 bit + (BOOL) Checkuseridcard: (NSString *) idcard{NSString *pattern = @ (^[0-9]{15}$) | ( [0-9] {17} ([0-9]|    X) $); Nspredicate *pred = [Nspredicate predicatewithformat: @SELF MATCHES%@, pattern];    BOOL IsMatch = [pred evaluatewithobject:idcard]; return isMatch;}         #pragma regular employee number, 12 digit + (BOOL) Checkemployeenumber: (NSString *) number{nsstring *pattern = @^[0-9]{12};    Nspredicate *pred = [nspredicate predicatewithformat: @SELF MATCHES%@, pattern];    BOOL IsMatch = [pred evaluatewithobject:number];     return isMatch;    } #pragma regular match url+ (BOOL) Checkurl: (NSString *) url{nsstring *pattern = @^[0-9a-za-z]{1,50};    Nspredicate *pred = [nspredicate predicatewithformat: @SELF MATCHES%@, pattern];    BOOL IsMatch = [pred evaluatewithobject:url];     return isMatch;  }

iOS uses common regular expressions to verify password ID phone number

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.