最少有一个大写和小写字母;
最少有一个数字;
最少八个字符;
func isPassWord(string: String) -> Bool {
let regex = "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,}$"
let allRegex : NSPredicate = NSPredicate(format: "SELF MATCHES %@", regex)
if allRegex.evaluate(with: string) {
return true
}
return false
}
网友评论