I'm trying to get this values - 10.547.889/0001-85, 00.219.460/0001-05 separated by groups, but the condition is that the pattern need start with executada(s):, can't be something like: r' - CNPJ:? (?P<cnpj>\d+\.\d+\.\d+\/\d+-\d+)'. So, the idea is start in executada(s) and get this groups.
Currently, my pattern just get the first group, I don't know how to get all them.
I'm using Python 3.8.5 and regex lib(doesn't re).
text = """
Solicite-se ao BANCO CENTRAL, via protocolo digital - SISBACEN ,
o BLOQUEIO de créditos existentes até o limite de R$ 30.257,45 (trinta mil, duzentos e
cinquenta e sete reais e quarenta e cinco centavos) da(s) executada(s): J.HENRIQUE
GALVANI COMERCIO DE ROUPAS - ME - CNPJ 10.547.889/0001-85, Riane Confecções de
Roupas Ltda - ME - CNPJ: 00.219.460/0001-05, Jose Henrique Galvani - CPF: 234.846.406-34
e Heliane Leonel Raymundo Galvani - CPF: 813.460.347-53, porventura
existentes junto a instituições financeiras, incluindo cartões de crédito, agenciadores
de pagamento, administradores de consórcio."""
pattern = r'executad\w(?:\(s\))?\W+(?:[\p{L}\s\-\.]+CNPJ\W+(?P<cnpj>\d+\.\d+\.\d+\/\d+-\d+),)+'
for item in regex.finditer(pattern, text, flags=regex.I|regex.S):
print(item.groupdict())
{'cnpj': '00.219.460/0001-05'}
I was waiting for:
{'cnpj': '00.219.460/0001-05'}
{'cnpj': '10.547.889/0001-85'}
So, can someone help me with this trouble?
flags=regex.S|regex.S=flags=regex.Sand it is redundant in your regex.flags=regex.I|regex.S. Thanks for warn