As I said in the title, I'm trying to use 'import re.compile()' to match an imported text file with a list of passwords. Some of them meet my criteria and some of them don't. It's just printing the whole file. My criteria is: at least 8 characters long have uppercase and lowercase letters at least one number
What's written in the txt file:
Password Attempts:
Password2
Positive77
Scandalous2
TryAgainFool99
password
lolipop22
I've been looking around on forums and trying some different methods but nothing seems to be working. Please help me.
with open('PasswordAttempts.txt') as file:
content = file.read()
import re
Regx = re.compile(r'[A-Za-z\d.]{8,}')
print(Regx.findall(content))
I expect the output to be just the passwords that meet the criteria but it's printing everything on the file. Here's the output:
['Password', 'Attempts', 'Password2', 'Positive77', 'Scandalous2', 'TryAgainFool99', 'password', 'lolipop22']