Regex Password complexity requires that any three
of the following four characteristics must be applied when creating or changing a password.
I am trying with the following code, but its not working for special characters
(?=^.{6,}$)((?=.*\d)(?=.*[A-Z])(?=.*[a-z])|(?=.*\d)(?=.*[^A-Za-z0-9])(?=.*[a-z])|(?=.*[^A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z])|(?=.*\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9]))^.*
I want my regex to be validated against the following 4 cases
Match cases
I think that a regex you can use is:
(?=^.{6,}$)(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[^A-Za-z0-9]).*
I'm not sure why you have so many or operators in your regex but this one matches if:
(?=^.{6,}$)
- String is > 5 chars(?=.*[0-9])
- Contains a digit(?=.*[A-Z])
- Contains an uppercase letter(?=.*[a-z])
- Contains a lowercase letter(?=.*[^A-Za-z0-9])
- A character not being alphanumeric.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With