Skip to content

Instantly share code, notes, and snippets.

@tiagotele
Created May 14, 2021 19:55
Show Gist options
  • Save tiagotele/b560bdbf525fe845fbc0f185049ec4cf to your computer and use it in GitHub Desktop.
Save tiagotele/b560bdbf525fe845fbc0f185049ec4cf to your computer and use it in GitHub Desktop.
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