Password complexity regex with number or special character

Viewed 538

I've got some regex that'll check incoming passwords for complexity requirements. However it's not robust enough for my needs.

((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,20})

It ensures that a password meets minimum length, contains characters of both cases and includes a number.

However I need to modify this so that it can contain a number and/or an allowed special character. I've even been given a list of allowed special characters.

I have two problems, delimiting the special characters and making the first condition do an and/or match for number or special.

I'd really appreciate advice from one of the regex gods round these parts.

The allowed special characters are: @%+\/'!#$^?:.(){}[]~-_

1 Answers
Related