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 city from full address using look up table of having cities info in DB using contains method, I’m able to match the cities from the full address but it is giving result as true even for the cities which has extra character at the first or last.

Please see the below example:

6048 Belladonna Cir NLas Vegas, NV 89142

From the above address, city is Las Vegas but it is having an extra character as N at the starting in my DB the cities look up table has info as Las Vegas, as per my task it should through False status but it is giving the result as True.

Input: 6048 Belladonna Cir NLas Vegas, NV 89142.contains(Las Vegas.ToTrim)

Result: Should be False but it is returning True.

It should validate the exact word(City) from the given input address

Can any one help me in fixing this issue

@Krishnakanth_Mathi

I hope you are using datatables

You can try this system.Text.RegularExpressions.Regex.IsMatch(str,"\b"+ lookupvalue + "\b")

Instead of contains try this…str is the address variable…lookupvalue is the lookup value variable

Cheers

2 Likes

Hi @Anil_G

Thanks for the instant help it worked and I’m able to Validate the Cities now

It worked for me with below syntax:

system.Text.RegularExpressions.Regex.IsMatch(str,“\b”+ lookupvalue + “\b”)

1 Like

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