Skip to content

Instantly share code, notes, and snippets.

View ThiagoDiasV's full-sized avatar
🐍

Thiago Dias ThiagoDiasV

🐍
View GitHub Profile
@ThiagoDiasV
ThiagoDiasV / regex.py
Created October 14, 2019 13:21
Python function to verify regex
def regex(padrao, texto):
import re
pattern = re.compile(r'{}'.format(padrao))
test_match = re.search(pattern, texto)
if test_match:
print('Deu match!')
matches = pattern.finditer(texto)
for match in matches:
print(f'Achei a regex "{padrao}" no texto entre as posições {match.span()[0]} e {match.span()[1]}')