Created
July 24, 2020 02:56
-
-
Save cassiasamp/5b497a65e9fb251efd277d870024186c to your computer and use it in GitHub Desktop.
Exemplo de código com regex em python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
senhas = """ | |
12345678 | |
J3sus0 | |
#Te5t300 | |
J*90j12374 | |
Michheeul | |
Monk3y6 | |
MARC3L0& | |
Ma3$ | |
#te5t300 | |
""" | |
# w: words --> [a-zA-Z] e também dígitos [0-9] e _ (underscore) | |
# d : digits --> [0-9] | |
# + : um ou mais | |
# | : ou (funciona como uma "soma", é uma agregação) | |
# padrao = re.compile(r'[\w\d]+[@#$]+|[@#$]+[\w\d]+|\w+[@#$]+\d+|\d+[@#$]+\w+') | |
padrao = re.compile(r'(?=.*[\d])(?=.*[a-z])(?=.*[A-Z])(?=.*[#@$]).{6,}') | |
combinacoes = padrao.findall(senhas) | |
for combinacao in combinacoes: | |
tamanho_correto = len(combinacao) <= 16 | |
if tamanho_correto: | |
print('senha válida:', combinacao) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment