Password validation regex

^(?=.*[^a-zA-Z])(?=.*[a-z])(?=.*[A-Z])\S{8,}$

should do. Be aware, though, that you’re only validating ASCII letters. Is Ä not a letter for your requirements?

\S means “any character except whitespace”, so by using this instead of the dot, and by anchoring the regex at the start and end of the string, we make sure that the string doesn’t contain any whitespace.

I also removed the unnecessary parentheses around the entire expression.

Leave a Comment