Help about regex - UIPath

I want to find a certain place in the address provided.

For example: 132, My Street, Kingston, New York, 12401

I want to find “New York” so I do this:

dtPlace.AsEnumerable.Where(function(x) System.Text.RegularExpressions.Regex.IsMatch(CurrentRow("Address").ToString.ToLower, "([^a-zA-Z0-9]|^)+" +x("State").ToString.ToLower + "([^a-zA-Z0-9]|$)+"))

This is working properly and gives me the exact result I want. My only problem is whenever I remove the comma like this (132 My Street Kingston New York 12401), it’s not working anymore. I want this to work, with or without comma.

How do I fix this? Thank you


How about the following?

dtPlace.AsEnumerable.Where(function(x) System.Text.RegularExpressions.Regex.IsMatch(CurrentRow("Address").ToString.ToLower, "\b"+x("State").ToString.ToLower + "\b"))



This is working, but another issue appeared.

Whenever I have comma: 132, My Street, Kingston, State of New York, 12401

It can’t read the data because in the “State” column I’m reading, it has only “New York” so it doesn’t match with “State of New York”. Thank you.


I think it’s no problem. Th following expression returns True because \b means word boundary.

System.Text.RegularExpressions.Regex.IsMatch("132, My Street, Kingston, State of New York, 12401".ToLower, "\b"+"New York".ToLower + "\b")

Can you check it actual run?


This one works, I have mistake so I just fix it. Thank you.

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