I want a regular expression to check that:
A password contains at least eight characters, including at least one number and includes both lower and uppercase letter
Just a small improvement for @anubhava's answer: Since special character are limited to the ones in the keyboard, use this for any special character:
^(?=.*?[A-Z])(?=(.*[a-z]){1,})(?=(.*[\d]){1,})(?=(.*[\W]){1,})(?!.*\s).{8,}$
This regex will enforce these rules: