/* 判斷用戶輸入的密碼是否符合規(guī)范啄糙,符合規(guī)范的密碼要求:
- 長(zhǎng)度大于6位
- 密碼中必須同時(shí)包含數(shù)字和字母
*/
+ (BOOL)passwdIsCharacterAndNum:(NSString *)passwd
{
if (passwd.length == 0)
{
return NO;
}
BOOL result = NO;
// 判斷長(zhǎng)度大于8位后再接著判斷是否同時(shí)包含數(shù)字和字符
NSString * regex = @"^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
result = [pred evaluateWithObject:passwd];
return result;
}