RegEx Question for Verifying Password Strength

I am looking for one regex for our password requirements. Passwords:

  • Must be at least 8 characters
  • Cannot contain spaces
  • Contains lowercase and UPPERCASE characters
  • Contains at least one digital digit
  • Contains at least one special character (i.e. any character is not 0-9,az,AZ )
+5
source share
2 answers

The idea and most of the work taken from http://www.zorched.net/2009/05/08/password-strength-validation-with-regular-expressions/

 ^\S*(?=\S{8,})(?=\S*[az])(?=\S*[AZ])(?=\S*[\d])(?=\S*[\W])\S*$ 

I used the main answer at the bottom of my post, but replaced all dots with \S to exclude whitespace, and moved some of the statements.

+4
source

It will most likely be easier to code the logic. A regular expression is used to match patterns. Passwords tend to be somewhat random strings, so the problem cannot be easily solved by regex. It is possible, but it will be mysteriously read and difficult to maintain.

+8
source

Source: https://habr.com/ru/post/947283/


All Articles