user2254936
user2254936

Reputation: 113

Get the value in the line above a word

I have the text below and would like to get the value of the line above the word
OUTRAS INFORMAÇÕES in this case the value 8.571.962,06

I did the following, but I found you very vulnerable.

^(.?)\s(?(\d+.\d+.\d+,\d+|\d+.\d+.\d+,\d+|\d+.\d+,\d+|\d+,\d+))\sOUTRAS INFORMA.?.*?ES

OCR:

NOME: TESTE DE SILVA SAURO
CPF: 785.981.970-84
DECLARAÇÃO DE AJUSTE ANUAL
IMPOSTO SOBRE A RENDA - PESSOA FÍSICA
EXERCICIO 2018 ANO-CALENDÁRIO 2017
EVOLUÇÃO PATRIMONIAL
Bens e direitos em 31/12/2016
Bens e direitos em 31/12/2017
Dividas conus rcais em 31/12/2016
Divisas e ônus reais em 31/12/2017
100.580.873.91
100.329. 110,32
9135,456,07
8.571.962,06
OUTRAS INFORMAÇÕES
Rendimentos isentos e não tributáveis



I'm using sitging to test https://regexr.com/

Upvotes: 0

Views: 470

Answers (1)

Yassin Hajaj
Yassin Hajaj

Reputation: 21995

This should do it (regex101)

^.*(?=\nOUTRAS INFORMAÇÕES)

Basically, do a lookahead to find a newline character with after it the OUTRAS INFORMAÇÕES line

Upvotes: 1

Related Questions