I want to implement a regex validaton for passwords in Swift? I have tried the following regex, but not successful
([(0-9)(A-Z)(!@#$%ˆ&*+-=<>)]+)([
public func isValidPassword() -> Bool {
let passwordRegex = "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z!@#$%^&*()\\-_=+{}|?>.<,:;~`’]{8,}$"
return NSPredicate(format: "SELF MATCHES %@", passwordRegex).evaluate(with: self)
}
If you need a quick fix. This is validation for a password with regex. Copy/paste in helper or extension file and use it.