# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"[^\"]*considerando|trabalho|social|providências|Réu:|Requerido:|Requerido\(s\):"
test_str = ("CONSIDERANDO o poder constitucional conferido ao Ministério\n"
"Público de expedir notificação e requisições para instruir procedimentos\n"
"administrativos de sua competência;\n"
"CONSI2DERANDO que a Constituição Federal dispõe que \"A\n"
"assistência social será prestada a quem dela necessitar, independentemente\n"
"de contribuição à. Requerido(s): seguridade social, e tem por objetivos: I - a\n"
"proteção à família, à maternidade, à infância, à adolescência e à velhice;\n"
"II - o amparo às crianças e adolescentes carentes; III - a promoção da\n"
"integração. Requerido: ao mercado de trabalho:\" e\n"
"CONSI2DERANDO os elementos. Réu: contidos no Relatório de Auditoria\n"
"da Controladoria-Geral Réu: da União nos itens 5.1.1.; 5.1.2.; 5.1.3.;\n"
"5.1.6.; 5.1.7.; 5.1.8.; 5.1.10. 5.2.1.; 5.2.2.; 5.2.3.; 5.3.2.; 5.3.5. e 5.3.9;\n"
"(Ministério do. Réu: Desenvolvimento Social e combate à Fome)\n"
"RESOLVE:\n"
"INSTAURAR o presente PROCEDIMENTO PREPARATÓRIO\n"
"Nº 03/2015, objetivando apurar as irregularidades apontadas no Relatório\n"
"de Auditoria da Controladoria-Geral da União nos itens 5.1.1.; 5.1.2.; 5.1.3.;\n"
"5.1.6.; 5.1.7.; 5.1.8.; 5.1.10. 5.2.1.; 5.2.2.; 5.2.3.; 5.3.2.; 5.3.5. e 5.3.9;\n"
"determinando, desde já, que sejam adotadas as seguintes providências.")
matches = re.search(regex, test_str)
if matches:
print ("Match was found at {start}-{end}: {match}".format(start = matches.start(), end = matches.end(), match = matches.group()))
for groupNum in range(0, len(matches.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = matches.start(groupNum), end = matches.end(groupNum), group = matches.group(groupNum)))
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
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