I need help regarding regex in uipath

Hello I’m beginner in using regex, I’m stuck with this problem.

Supposedly, I’m extracting 3 different data (“Province”, “Municipality” and “Barangay”) from different address. I got this problem wherein it does not match my data.

sample address: BLOCK 50 LOT 2 11TH COR 20TH ST BRGY 183 VILLAMOR PASAY METRO MANILA

I want the output to look like this:

Province = Metro Manila
Municipality = Pasay
Barangay = Barangay 183

My problem is I can’t output Barangay 183

My regex look like this:

dtRef.AsEnumerable().Where(Function(x) System.Text.RegularExpressions.Regex.IsMatch(CurrentRowData("Address").ToString().ToLower().Replace(",", ""), "\b(?i)(Brgy|BRGY|Barangay|BARANGAY)\W*" + x("Barangay").ToString.ToLower + "\b")).Count()

Another example is this address: 311 PUROK 1 BARANGAY MATAAS NA KAHOY GENERAL M. NATIVIDAD NUEVA ECIJA

Expected Output:

Province = Nueva Ecija
Municipality = General M. Natividad
Barangay = Mataas Na Kahoy

But I’m getting this output:

Province = Nueva Ecija
Municipality = General M. Natividad
Barangay = Mataas

@Shoji

One you get the province and mulcipality…replace those values with empty then you will be left out only with barangay and the remaining full string you need…

Then you can split with barangay or brgy and then get the value together

Cheers

Hi @Shoji ,

I believe the details for this process is also related to your previous posts created. Could you also mention the posts which this is related to ? Or Could you give more details of what the dtRef datatable contains ?

Also, the Expression provided above just gets the count of the matching condition.

Let us know with more details of inputs and what is implemented currently to get the output that you are receiving. We will be able to analyse and help much faster.

I’ll try thanks

1 Like

dtRef are lists of areas, it’s my reference. I’m matching the address provided to my dtRef. So if it match the condition then I’ll just write the matched data in my excel.