1. 程式人生 > >6-15位字母加數字密碼驗證

6-15位字母加數字密碼驗證

- (BOOL)checkPassword:(NSString *) password

{

NSString *pattern = @"^[A-Za-z0-9]{6,15}$";

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

    BOOL isMatch = [pred evaluateWithObject:password];

    return isMatch;

}