I need to validate passwords that needs to fulfill the following rules:
I can't figure out how to validate this using regular expressions. Can anybody help me?
^(?=.*[A-Z])(?=.*(?:\d|-))(?!.*(.).*\1)[a-zA-Z]{2}.{4,}[a-zA-Z]{2}$
Try this.See demo.
https://regex101.com/r/eZ0yP4/12
As you can see step by step all conditions are met with the help of lookahead.
(?=.*[A-Z])===at least one Capital
(?=.*(?:\d|-))===at least one digit or -
(?!.*(.).*\1)=== no duplicates
[a-zA-Z]{2}.{4,}[a-zA-Z]{2}===alphabetic characters as first two and last two.
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