Find Exact word

Hello Team,
I want to find exact word in sentence,

eg : AV, AVE,AVENUE
Sentence: 2687 AVE 90

I have to replace AVE with AVE#,
Please guide

U can use replace function in string to replace the AVE with AVE #

like string_var= 2687 AVE 90

string_var.Replace(“AVE”,“AVE#”)

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed:

Hi, see my topic and check the possibilities:

Hey,

First i need to find out if the sentence contains exact keyword,
How can it be done ?

Thanks

IF:
your_String.Contains("Word") (needs to be accurately reflected)
or
your_String.ToUpper.Contains("WORD") (convert text to uppercase and match to uppercase)
or
your_String.ToLower.Contains("word") (convert text to lowercase and match to lowercase)

@msalesforce777

Check as below to check

First use AVE in IF condition, In Else continue with AV and in Else continue with AVENUE

Hope this may help you

Thanks

2 Likes

If i give input as “AV” then contains will be true in “AVE” Case,i need to exact match “AVE”, any suggestions

There are almost 2000 records present, Cannot use if else to find and replace

No worries. If your AVE has spaces around, add them to the condition. Like this:

Hi,

Can you try the following expressions?

Check

System.Text.RegularExpressions.Regex.IsMatch(yourString,"\bAV\b")

Replace

System.Text.RegularExpressions.Regex.Replace(yourString,"\bAVE\b","AVE#")

Regards,

2 Likes

IF word is going to be anything from AVE, AVENUE then use below…
If it can be AV also then just remove E from AVE in given regular expression

This will work if only “AV” is present, how can i check a exact word in sentence

Hi @msalesforce777

Please try the below method.

Feel free to reach us at any time if you have doubts. Thanks.

Happy Automation

1 Like

Hi,

How about the following?

Check:

System.Text.RegularExpressions.Regex.IsMatch(yourString,"\bAV\b|\bAVE\b|\bAVENUE\b")

Replace:

System.Text.RegularExpressions.Regex.Replace(yourString,"\bAV\b|\bAVE\b|\bAVENUE\b","AVE#")

Regards,

2 Likes

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