I would like to test if the input value meets the criterias:
- at least one lower case letter
- at least one upper case letter
- at least one digit
- at least one character that is non \w
It seems the regex I programmed only follows this specific order like: abCD99$%
But if I shuffled the sequence, the regex doesn't work anymore: CD99ab$%
Anyone knows what the problem is please? Cheers in advance.
import re
# Asks user for an input
print('Please enter a password for checking its strength:')
pwd = input('> ')
#Test the input to see if it is more than 8 characters
if not len(pwd) < 8:
pwdRegex = re.compile(r'([a-z]+)([A-Z]+)([0-9]+)(\W+)') #order problem
if not pwdRegex.search(pwd) == None:
print('Password OK.')
else:
print('Please make sure password fulfills requirements!')
else:
print('Characters must not be less than 8 characters!')