0

I need to create a pattern to stop the match at the first occurrence of INTERESSADO.

My current pattern stop in the last.

My pattern: \nreclamado: (?P<cpf_cnpj_content>[\p{L}\s\d\D]+\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2})\n\w+ interessado

enter image description here

I don't understand yet what I need to change to fix it :(

Text to test:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer eget varius ante. Sed posuere quis ante sit amet efficitur. Proin augue lacus, ornare sed nibh nec, rhoncus ornare lacus. Vestibulum est justo, tincidunt a nulla a, sagittis vestibulum eros. Integer eget lacus lacus. Donec luctus leo ut turpis egestas, eu sagittis arcu imperdiet. Sed ultricies convallis ante eu dignissim. Morbi a est arcu. Nulla non ullamcorper metus, nec porttitor lectus. Aenean congue ligula augue, ut auctor orci elementum quis. Vestibulum turpis quam, scelerisque ut vestibulum non, dictum at ligula. Integer tristique rhoncus nibh sit amet rutrum.
RECLAMADO: JUST A TEST.
RECLAMADO: JUST A TEST -
CNPJ: 99.999.999/9999-99
RECLAMADO: JUST A TEST - CPF: 999.999.999-99
ADVOGADO: JUST A TEST - OAB: AB9999
RECLAMADO: JUST A TEST - CPF: 999.999.999-99
RECLAMADO: JUST A TEST - CNPJ: 99.999.999/9999-99
RECLAMADO: JUST A TEST - CNPJ: 99.999.999/9999-99
RECLAMADO: JUST A TEST - CPF: 999.999.999-99
RECLAMADO: JUST A TEST - CNPJ: 99.999.999/9999-99
RECLAMADO: JUST A TEST - CPF: 999.999.999-99
RECLAMADO: JUST A TEST - CNPJ:
99.999.999/9999-99
RECLAMADO: JUST A TEST - CNPJ: 99.999.999/9999-99
RECLAMADO: JUST A TEST - CNPJ: 99.999.999/9999-99
RECLAMADO: JUST A TEST - CNPJ:
99.999.999/9999-99
RECLAMADO: JUST A TEST - CNPJ:
99.999.999/9999-99
RECLAMADO: JUST A TEST
- CNPJ: 99.999.999/9999-99
RECLAMADO: JUST A TEST

- CNPJ: 99.999.999/9999-99
RECLAMADO: JUST A TEST - CNPJ:
99.999.999/9999-99
RECLAMADO: JUST A TEST - CNPJ:
99.999.999/9999-99
RECLAMADO: JUST A TEST - CNPJ: 99.999.999/9999-99
RECLAMADO: JUST A TEST - CNPJ: 99.999.999/9999-99
TERCEIRO INTERESSADO: JUST A TEST
TERCEIRO INTERESSADO: JUST A TEST - CNPJ:
99.999.999/9999-99
TERCEIRO INTERESSADO: JUST A TEST
- CNPJ: 99.999.999/9999-99
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer eget varius ante. Sed posuere quis ante sit amet efficitur. Proin augue lacus, ornare sed nibh nec, rhoncus ornare lacus. Vestibulum est justo, tincidunt a nulla a, sagittis vestibulum eros. Integer eget lacus lacus. Donec luctus leo ut turpis egestas, eu sagittis arcu imperdiet. Sed ultricies convallis ante eu dignissim. Morbi a est arcu. Nulla non ullamcorper metus, nec porttitor lectus. Aenean congue ligula augue, ut auctor orci elementum quis. Vestibulum turpis quam, scelerisque ut vestibulum non, dictum at ligula. Integer tristique rhoncus nibh sit amet rutrum.
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
Daniel Bailo
  • 127
  • 1
  • 6
  • 1
    `[\p{L}\s\d\D]+` is equal to `[\d\D]+` and matches any 1+ chars as many as possible, going through all occurrences of any other patterns to match the rest of the subpatterns in the rightmost position. – Wiktor Stribiżew Nov 24 '21 at 20:57
  • 2
    Maybe you just need a lazy quantifier? `\nreclamado: (?P[\d\D]+?\d{2}\.\d{3}\.\d{3}/\d{4}-\d{2})\n\w+ interessado`? See https://regex101.com/r/sTNp3J/1 (BTW, test Python `re` regexps with the `Python` option at regex101, not PCRE). Looks what you need. – Wiktor Stribiżew Nov 24 '21 at 20:58
  • ye, solved it! I saw the other question, but I didn't understand the asnwer about the lazy quantifier :( – Daniel Bailo Nov 24 '21 at 21:09
  • thanks for your attention again! – Daniel Bailo Nov 24 '21 at 21:10
  • 1
    That is because you camouflaged the `(?s:.*)` pattern as `[\p{L}\s\d\D]+`. – Wiktor Stribiżew Nov 24 '21 at 21:18

0 Answers0