import re
regex = re.compile((r"(uno|dos|tres|cuatro|cinco|seis|siete|ocho|nueve|diez|once|doce|trece|catorce|quince|dieciséis|diecisiete|dieciocho|diecinueve|veinte|veintiuno\n"
r"|veintidós|veintitrés|veinticuatro|veinticinco|veintiséis|veintisiete|veintiocho|veintinueve|treinta|treinta y uno)(?:[ ]de[ ])?(enero|febrero|\n"
r"marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)[ ]?(?:de|del)?[ ]?(?:año)?[ ]?(dos[ ])?(mil)[ ]?(cien|doscient\n"
r"os|trescientos|cuatrocientos|quinientos|seiscientos|setecientos|ochocientos|novecientos)?[ ]?(diez|once|doce|trece|catorce|quince|dieciséis|die\n"
r"cisiete|dieciocho|diecinueve|veinte|veintiuno|veintidós|veintitrés|veinticuatro|veinticinco|veintiséis|veintisiete|veintiocho|veintinueve|treinta|cuarenta|cincuenta|sesenta|setenta|ochenta|noventa)?(?:[ ]y[ ])?(uno|dos|tres|cuatro|cinco|seis|siete|ocho|nueve)?"), flags=re.MULTILINE | re.IGNORECASE)
test_str = "siete de Enero dos mil diecinueve"
matches = regex.finditer(test_str)
for match_num, match in enumerate(matches, start=1):
print(f"Match {match_num} was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html