I'm trying to develop a regex for password validation that requires the following criteria,
- 1 Uppercase
- 1 Numeric
- 8-45 length
- Ascii only as specified in OWASP list
I came up with this lookahead regex but unfortunately it doesn't seem to work with non-ascii characters.
^(?=.*[A-Z])(?=.*\d)(?=[\x20-\x7E]).{8,45}$
Tested on,
ABCD1234abcd!" #$%&'()*+,-./:;<=>?@[\]^_`{|}~
However, doesn't seem to work with non-ascii characters i.e. it still matches the non-ascii characters despite of \x20-\x7E
,
ABCD1234abcd!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~£
Notice that I do want to include the whitespace as well.
Anything obvious that I'm doing wrong here ?