Key Word Check and Counter

Hi All, I have an automation created in studio x that reads through a list of words in excel and if found, marks the adjacent cell as found. I was hoping to add onto this automation and make it so that the number of times (counter) a word is found is also outputted? Thank you in advance

@trevor.thenga

to get count you can try this …if this count is zero that means the word is not found…

Use assign activity as below and create a variable countOfWords, and str is where the data you are searching is present

countOfWords = System.Text.RegularExpressions.Regex.Matches(str,"WordToSearch").Count

cheers

Thank you for the assistance! Where in my workflow should I add this activity? After my for each row in data table if statement?

@trevor.thenga

In the if condition i guess you are using str.contains…instead of that use countofrows>0

And this should ideally be inside loop…I believe your loop is on the words you want to check

Cheers

This is my current condition for my if statement “mystring.Contains(” “+( CurrentRow.Item(“Acronym”).ToString)+” “) Or mystring.Contains(”(“+( CurrentRow.Item(“Acronym”).ToString)+”)“) Or mystring.Contains(Chr(34)+( CurrentRow.Item(“Acronym”).ToString)+Chr(34))” can you please advise how to edit and add what you are mentioning?

@trevor.thenga

Please use this

System.Text.RegularExpressions.Regex.Matches(MyString,CurrentRow.Item(“Acronym”).ToString).Count > 0

when matching found it goes to then when not found goes to else…and inside then use without >0 to get the count of words

Hope this helps

cheers

cheers

should i add that directly after my current condition?

@trevor.thenga

You can remove the current condition and add this

cheers

awesome thank you, and can you please elaborate on “when matching found it goes to then when not found goes to else…and inside then use without >0 to get the count of words”

@trevor.thenga

Basically youa re using this in if condition right

When the acronym value is present in the string then the bot moves to then side of if condition as it is found

When not found it moves to else side

And as you need count you can use same expression to count System.Text.RegularExpressions.Regex.Matches(MyString,CurrentRow.Item(“Acronym”).ToString).Count

Hope this helps

Cheers