I am currently learning python and do some excercices and have the following problem. I take user input for Password which should be at least 8 chars long, have capital letter, small letter and a special char.
What I would like to understand is, can I combine all of the above in one regex as below, or I need to list each and every case separately (see below).
Using only one:
whole_check = re.compile(r'''(
[A-Z] #Check for capital letter
\d #Check for number
\W #check for special character)''', re.VERBOSE)
So how can I do a multiple if match here. As example:
if not [A-Z]:
do something
if not \d:
do something
The only other option is if i define each category in a separate variable:
cap_letter = re.compile(r'[A-Z]')
small_letter = re.compile(r'[a-z]')
Thanks for clearing this for me.
Aucun commentaire:
Enregistrer un commentaire