Match regex after nth ocurence

Hi everyone,

I am trying to capture multiple adresses from multiple pdf, with each pdf containing more than 1 adress, using regex and matches.
An example of the string for one pdf is the following:

Husnummer Prefix byggnadsid Byggnadsid Orsak till avvikelse
36 1 2519764 Adressuppgifter är fel/saknas

Adress Postnummer Postort Huvudadress
Nämndemansgården 30 58643 Linköping

Adress Postnummer Postort Huvudadress
Nämndemansgården 32 58643 Linköping

Adress Postnummer Postort Huvudadress
Nämndemansgården 34 58643 LinköpingByggnaden - Egenskaper
Typkod Byggnadskategori
320 - Hyreshusenhet, huvudsakligen bostäder Flerbostadshus*

I am using the following regex : (?<=Adress.Postnummer.Postort.Huvudadress[\n\r])(\w+.\w+).
In UiPath, the strings i want it to return are all highlighted.
(Nämndemansgården 30,Nämndemansgården 32, and Nämndemansgården 34)
I know it has something to do with arrays from previous posts, but can’t figure it out.

I now have 2 issues:
1.None of them get written to the output excel file.
2. How do i get multiple results?
I was trying to make it write the first occurance to one cell, the second occurance to another cell and so on, but I don’t mind if it writes all results in one excel cell with a seperator if this is easier.
Please find attached the workflow i have thus far. Multiple_PDF_Data_Extration_Variousadresses.xaml (17.7 KB)

Hi ,

For multiple returns you can use ,

Matches(String, Int32)
Searches the specified input string for all occurrences of a regular expression, beginning at the specified starting position in the string.

EX : rgx.Matches(sentence)

1 Like

@Carl_Van_Cauwenberge Try this Regex :

Thank you,

However, I still don’t see how i can get the multiple matches to an output (excel)

I’m sorry, I am not familiar with that.
How exactly would i use that ?

If you have the right expression, all you need is Matches activity, it will return a collection of the Match object, then you can use a For Each to iterate them and add to excel.