I’m trying to validate the city from full address using look up table of cities info in DB using contains, I’m able to match the cities from the full address but it is giving result as true even for cities which has extra character at the first or last

I’m trying to validate the State and Zipcode from address using look up table of state and Zipcode info in DB using contains, I have identified the state and zipcode from the address using Regex, now the task is I need to identify if the address having the state and zipcode twice or not if this given address has state and zipcode as twice then it should give the result as false and should return to fetch new address and pass it to Regex for next transaction validation

Input: 6048 Belladonna NV 89142 Cir Las Vegas, NV 89142

In the above address this has state and zipcode twice, how can I trace the given input has state and zipcode as twice

I have used Regex to retrieve the state and zipcode from the input address, now need to know how can i validate with this output whether this state and zipcode info twice or not if it is repeated twice it should print the log message and the same should write to an excel sheet

Please help me in solving this task
Please find the attached screenshot

Hi @Krishnakanth_Mathi ,

You can achieve this by getting the count of matches, if it’s greater than 1 then you can confirm that it’s repeating.

Hope this helps

Regards,

1 Like

Hi,

How about the following?

mc = System.Text.RegularExpressions.Regex.Matches(yourString,"\b(?<STATE>[A-Z]{2})\s+(?<ZIP>\d{5})\b")

Then check mc.count>1

Sample20230406-1aL.zip (2.7 KB)

The above pattern is for we can extract state and zip later. If it’s unnecessary, the following pattern will work.

\b[A-Z]{2}\s+\d{5}\b

Regards,

1 Like

Hi @Yoichi

Thanks for the support it worked for me

1 Like

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