I am making a sign-in/up function on Swift. I am trying to validate a password using regex. The passwords have the following requirements
- At least 7 characters long
- At least one uppercase letter
- At least one number
This is the validation regex I was using: "^(?=.[A-Z])(?=.[0-9]){7}$"
And this is my code
let passwordTest = NSPredicate(format: "SELF MATCHES %@", "^(?=.[A-Z])(?=.[0-9]){7}$")
Whenever I try to log in with a password that meets these requirements (eg. Greatpass13), Xcode gives me an error saying
Thread 1: "Can't do regex matching, reason: (Can't open pattern U_REGEX_RULE_SYNTAX (string Greatpass13, pattern ^(?=.[A-Z])(?=.[0-9]){7}$, case 0, canon 0))"