# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(FACTURA.*?(?!ELECTR))"
test_str = ("CLINICA LAS UBNDES S.A. R.U.T.: 93.930.000-7\n"
"HOSPÍ ES IONAMIENTO\n"
"CASA TAL: e e - LAS CONDES - SANTIAGO FACTURA NO AFECTA O\n"
"SP” CLÍNICA SUCURSALES: LO FONTECILLA 4174 - LAS CONDES EXENTA ELECTRONICA\n"
"CHICUREO S/N - COLINA N* 211918\n"
"E LAS CONDES EMILLE ALLAIS £91 - LO BARNECHEA\n"
"CAMINO A VALLE NEVADO 41333 - LO BARNECHEA\n"
"LOS PRESIDENTES $8950 - PEÑALOLEN\n"
"S.l.1. - SANTIAGO ORIENTE\n"
"www.clc.cl\n"
"Fecha Emisión : 08-02-2023 RUT : 10.143.057-K\n"
"Señor(es) : NALLY FERNANDEZ MARIA SOLEDAD\n"
"Dirección : MARTIN DE ZAMORA 6306 Vencimiento\n"
"Ciudad : SANTIAGO Comuna : LAS CONDES\n"
"Giro : ACTIVIDADES NO ESPECIFICADAS Forma de Pago _ : CONTADO\n"
"1.698.196\n"
"DESCRIPCIÓN\n"
"PETCT\n"
"1.698.196\n"
"102001\n"
"cuy SÉ Y\n"
"3 |\n"
"Ss $\n"
"Y OCHO MIL CIE\n"
"SON: UN MILLÓN SEISCIENTOS NOVENTA AEB NENENTA\n"
"SEIS PESOS\n"
"MONTO DSCTO [5 o\n"
"MONTO EXENTO |$ 1.698.196\n"
"1.698.196\n"
"01: j d j sio\n"
"y i We\n"
"Timbre Electronico Sil fique Documento: ww\n"
"Res. 138 de 29-11-2011 Veri\n")
matches = re.finditer(regex, test_str, re.DOTALL | re.IGNORECASE | re.MULTILINE)
for matchNum, match in enumerate(matches, start=1):
print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
for groupNum in range(0, len(match.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.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