正则表达式1

/**

* 功能: 判断长度大于6位小于20位并是否同时包含且只有数字和字母

*/

+(BOOL)judgePassWordLegal:(NSString *)text{

BOOL result = false;

if ([text length] >= 6){

NSString * regex = @"^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$";

NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];

result = [pred evaluateWithObject:text];

}

return result;

}

你可能感兴趣的:(正则表达式1)