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