import re
regex = re.compile(r"^((?:.+?, .+?;)*?(?:[^;\s]+?, .+?)\.)([^;]+?\.).*$", flags=re.MULTILINE)
test_str = ("DI MAIO, P. The Missing Pragmatic Link in the Semantic Web. Business Intelligence Advisory Service Executive Update. v. 8, n. 7, 2008.\n\n"
"ECO, U. Lector in Fabula: la cooperación interpretativa en el texto narrativo. Barcelona: Lumen, 1987\n\n"
"ECO, U. O conceito de texto. São Paulo: T. A. Q. /EDUSP, 1984.\n\n"
"ECO, U. Obra aberta: forma e indeterminação nas poéticas contemporâneas. São Paulo: Perspectiva, 1988.\n\n"
"ECO, U. Os limites da interpretação. São Paulo: Pioneira, 2000.\n\n"
"EDMONDS, B. The Pragmatic Roots of Context. In: PROC. OF THE 2ND INTERNATIONAL AND INTERDISCIPLINARY CONFERENCE ON MODELING AND USING CONTEXT. Berlin; Heidelberg; New York, v. 1688, 1999. Anais… v. 1688, p. 119-132, 1999.\n\n"
"BERNERS-LEE, T. Semantic Web Concepts. 2005a. Disponível em: http://www.w3.org/2005/Talks/0517-boit-tbl. Acesso em: 25 set. 2014\n\n"
"BERNERS-LEE, T. Web for real people. 2005b. Disponível em . Acesso em: 25 set. 2014.\n\n"
"BERNERS-LEE, T.; CAILLIAU, R. WorldWideWeb: Proposal for a HyperText Project. 1990. Disponível em: < http://www.w3.org/Proposal.html >. Acesso em: 13 out. 2014.\n\n"
"BERNERS-LEE, T.; HENDLER, J.; LASSILA, O. The semantic web: a new form of web content that is meaningful to computers will unleash a revolution of new possibilities. New York: Scientific American, 2001. Disponível em: http://www.sciam.com/2001/050lissue/0501berners-lee.html. Acesso em: 13 out. 2014.")
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