+ 3
Regex
I have this code. https://code.sololearn.com/cOqDxfao5JQx/?ref=app I want to make it valid if it consist atleast one Capital letter and 1 number. It works for AB1 but not for 1BA. Any idea ?
5 Answers
+ 2
Your code checks for a letter followed by a digit. All you need to add is a check for a digit followed by a letter. To do that replace line 3 with the following:
if re.search(r'([A-Z])+([0-9])+',password) or re.search(r'([0-9]+[A-Z]+', password):
+ 1
It looks for your variables order, you searched letter+digit
+ 1
With lookaround
'(?=.*[A-Z])(?=.*[0-9])'
+ 1
It's late but is it what you were looking for?
https://code.sololearn.com/cy7Eqxm56q0Z/?ref=app
0
Dunaev Evgenii how to make it right if i want from both sides