I've written this regex that I need to test against a set of rules in Java. The rules are:
- At least one upper case character (A-Z)
- At least one lower case character (a-z)
- At least one digit (0-9)
- At least one special character (Punctuation)
- Password should not start with a digit
- Password should not end with a special character
This is the regex that I've written.
[a-zA-Z\w\D][a-zA-Z0-9\w][a-zA-Z0-9].$
It sometimes works, and sometimes it doesn't. And I can't figure out why! I would really appreciate your help in getting this right.