How to count the ocurrences of a word in a scraped text?

Hi,

I’m automating a process that need to count the number of occurrences of a word in a scraped text. For example:

Text: Hi, Maria is working at home, because Maria is a freelance.

In this string, how the robot can know the word Maria is repeated two times?

Thanks for your responses

1 Like

One example:
int count = yourText.Split(" "c, "."c, ","c).Where(Function(x) x.Equals("Maria")).Count

1 Like

Hey @nSangui

You can try this as well:

String str = "Hi, Maria is working at home, because Maria is a freelance"

Regex.Matches(str,Regex.Escape("Maria")).Count.ToString

Regards…!!
Aksh

3 Likes

Split(strWord,"Maria").Length-1

6 Likes

Hey @aksh1yadav how to do above thing in Uipath studio?

Please see attached which should count the occurances of “Maria” in in ‘str’ variable. Probably a better way of doing this but it works at least.

countWord.xaml (4.7 KB)

Here is an example I made using vvaidya’s concept. Note I used .ToLower to prevent any upper / lowercase issues.

Main.xaml (6.8 KB)