Regex matching system

Hi i want to match the words Mo i Rana. I cant figure out

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 Mo i Rana\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

@langsem U can see below thread that will help.

Did look at it, but its working in my case :confused: the thing its that Mo i Rana its name of branch, so i could be something different on another pdf file. It could be Oslo, Kristiandsand, Sandefjord Kilen etc
So need a regex expression that look intbettwen maybe Avdeling and Bank i tried with (?<=Avdeling\s)(.*)(?=nBank) but it gave me blank :confused:

You can use this regex to find those two words that you wanted

\w*(Mo|Rana)

If you want regex to look between two words you can use something like this :

Avdeling([\s\S]*?)Bank then select group 1 matching with Assing activity : StringThatYouWant = OutputRegex(0).Groups(1).Value

its almost working, it gives me another line aswell tho :confused:

currently my assign look like this

branch = System.Text.RegularExpressions.Regex.Match(PDF_INVOICE_STRING, “(?<=Avdeling)\s\w+”).ToString

That only finds words thats one word like OSLO, Sandefjord etc

So its missing words that contains like 2-3 arrays like Mo i Rana , Sandefjord Kilen etc

Try this once:-
(?<=Avdeling\s).*(?=\snBank)

Yes, because there is multiple matches.
When you use Matches Activity in UiPath you can use this Regex expression, and then the output will be in RegularExpression Array, so you need to select first match ( the 0 index)

Main.xaml (5.9 KB)

Hope this helps

no match :confused:

Also, if you have multiple result you can always use For Each to get each element like this :slight_smile:

almost working, the ouput its Mo i Rana\r\n

Yes, because the \r\n is in your text

so a replace \r\n\
would work ?

You can use Replace string method

Main.xaml (6.9 KB)

1 Like

Did it work?

1 Like

yes thanks!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.