Find a specific word and extract it with regex

Hello i am trying to assign a variable to a speifcif line for later use.

this its what the uipath sees on the pdf

“Hurtigruta Carglass AS\r\n1(1)\r\n(Ensjøvn. 17)\r\nPOSTBOKS 6452 ETTERSTAD\r\n0605 OSLO\r\nForetaksregisteret NO 985758220 MVA\r\nKunde 100454 Avdeling Alnabru\r\nBank\r\n4202 33 70055\r\nTRYG FORSIKRING\r\nIBAN NO77 4202 3370 055\r\nPostboks 7070\r\nSWIFT SPTRNO22\r\n5020 BERGEN\r\nTlf 98709500\r\nFax 22 70 76 01\r\nregnskap@hurtigruta.no\r\nDeres referanse\r\nwww.hurtigruta.no\r\nFAKTURA 14780866\r\nFakturadato 08.06.2019 Skadedato 07.06.2019\r\nForfallsdato 08.07.2019 Reg.nr. EK71995 Vår referanse Avdeling Alnabru\r\nKID147808661\r\nLeveringsdato 07.06.2019 Kundens ordrenr\r\n0000456218\r\nVarenr Varetekst Antall Pris % Sum\r\nRep av frontrute\r\n50 REP-1 1,0 STK 650,00 650,00\r\nm.v.a. av kr 650,00 162,50\r\nTotalsum: 812,50\r\nAvrunding 0,50\r\nSum å betale: 813,00\r\nBankkontonummer: 4202 33 70055\r\nBiler med fradragsrett for merverdiavgift, skal svare denne avgiften i tillegg til en eventuell egenandel.\r\nFor disse bilene dekker forsikringsselskapet kun netto faktura.”

I want to extract TRYG FORSIKRING. Only thing its that this can change based on pdf files, so i cant search for TRYG FORSIKRING itself,

Thanks in advance

1 Like

You can try getting the text between Bank and IBAN and the split it by \r\n and get the 3rd item
(?=Bank)(.*)(?<=IBAN)

Did not work :frowning:

Did not work :frowning:

User https://activities.uipath.com/docs/matches activity, and get the 1st group .

It prints out as a big bunch of one text file. So they are not grouped

Could you share a screenshot of your workflow?

workflow

Forsikring its = TRYG FORSIKRING; its just a variable that i have made. I want to assign what ever i get from the pdf in that field to the variable Forsirking. Like TRYG FORSIKRING can be another value on another pdf file, but will be in same postion at all time. Its Insurance btw

Why not use match activity? The text you’re willing to get will always be between BANK and IBAN?

InStr function also will work for PDF output data verification to identify correct PDF.

InStr(UCase(str),“TRYG FORSIKRING”)<>0 --> pass this in If condition

the pdf looks like this

in other term, TRYG FORSIKRING its the name of the insurance and will not always be TRYG FORSIKRING on another pdf it could be CODAN , IF, GJENSIDIGE etc

Yes sometimes there can be no text there, also. So can be two conditions. One with isurance name and one without