Created
May 14, 2021 19:55
-
-
Save tiagotele/b560bdbf525fe845fbc0f185049ec4cf to your computer and use it in GitHub Desktop.
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 | |
regex_original = r"^[a-zA-Z0-9]+ ([a-zA-Z0-9]+ *)+$" | |
regex_latin = r"^[a-zA-ZÀ-ÿ0-9]+ ([a-zA-ZÀ-ÿ0-9]+ *)+$" | |
names = [ "Nome Sobrenome", | |
"José Luiz", | |
"Maria Conceição", | |
"007 agente", | |
"Pedro Primeiro", | |
"Pedro 01", | |
"9 01", | |
"Bartô Galeno", | |
"### ***", | |
"àgora vãi" | |
] | |
def verify_names_for_regex(regex_exp): | |
p = re.compile(regex_exp ) | |
for name in names: | |
if p.match(name) is not None: | |
print("ok ", name,) | |
else: | |
print("ERROR ", name,) | |
verify_names_for_regex(regex_original) | |
print("___________________") | |
verify_names_for_regex(regex_latin) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment