Skip to content

Instantly share code, notes, and snippets.

@cassiasamp
Created July 24, 2020 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cassiasamp/5b497a65e9fb251efd277d870024186c to your computer and use it in GitHub Desktop.
Save cassiasamp/5b497a65e9fb251efd277d870024186c to your computer and use it in GitHub Desktop.
Exemplo de código com regex em python
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