import re
regex = re.compile(r"((?:(?:(?:(?:Cass\.?(?:(?:(?:(?: | | |\\1e|\\1f)*))(?:(?:fr.)|(?:aud\.(?:(?:(?: | | |\\1e|\\1f)*))pl(?:é|e|é)n\.)))?)|(?:C\.?E\.?D\.?H\.?)|(?:Cour eur\. D\.?H\.?)),?))(?:(?:(?: | | |\\1e|\\1f)*))(?:(?:(?:1<sup>er?<\/sup>|[0-9][0-9]?)(?:(?:(?: | | |\\1e|\\1f)*))(?:janvier|f(?:é|e|é)vrier|mars|avril|mai|juin|juillet|ao(?:û|u|û)t|septembre|octobre|novembre|d(?:é|e|é)cembre|januari|februari|maart|april|mei|juni|juli|augustus|sept(?:ember|\.)|oktober|nov(?:ember|\.)|dec(?:ember|\.))(?:(?:(?: | | |\\1e|\\1f)*))([1-2][0-9]{3}),?))(?:(?:(?:(?: | | |\\1e|\\1f)*))(?:[A-Z]+\.[0-9]+\.[0-9]+\.[A-Z]+\.))?(?:,?(?:(?:(?: | | |\\1e|\\1f)*))))((?:<[^>]*>)?(?:(?:(?: | | |\\1e|\\1f)*))(?:Larcier(?:(?:(?: | | |\\1e|\\1f)*))[Cc]ass(?:ation)?\.?)(?:(?:(?: | | |\\1e|\\1f)*))(?:<\s*\/[^>]*>)?(?:\.?,?(?:(?:(?: | | |\\1e|\\1f)*)))?(?:(?:(?:[nN]rs?\.?|(?:[nN](?:(?:(?: | | |\\1e|\\1f)*))<sup>o<\/sup>\.?)|[nN](?:(?:(?: | | |\\1e|\\1f)*))(?:°|˚|o)s?\.?|[Aa]fl\.))(?:(?:(?: | | |\\1e|\\1f)*)))([0-9]+))")
test_str = "C'est dingue que ceci Cass., 7 février 2001, Larcier Cass., n° 481 soit catché !"
match = regex.search(test_str)
if match:
print(f"Match 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