iOS regular expression to determine the password

Source: Internet
Author: User

IOS Regular Expressions

    • Can't all be numbers
    • Not all the letters.
    • must contain letters and numbers
    • 6-20 Guests
-(BOOL)checkPassWord{    //6-20位数字和字母组成    NSString *regex = @"^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$";    NSPredicate *   pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];    if ([pred evaluateWithObject:self]) {        returnYES ;    }else        returnNO;}

^(?! [0-9]+ )(?![a?ZA?Z ]+ ) [0-9a-za-z]{6,20}$

    • ^ matches the beginning of a line
    • (?! [0-9]+$] predict that the position is not all numbers behind
    • (?! [a-za-z]+$] predict that the position is not all letters behind
    • [0-9a-za-z] {6,20} consists of 8-16 digits or this letter
    • $ Match Line End position

Note: (?! XXXX) is the negative 0-wide assertion of a regular expression of a form that identifies the pre-position after it is not the XXXX character.

iOS regular expression to determine the password

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.