Occurance of a word in a text

If i have a text in a variable, how can i now the number of times a world is mention in that text?

Thanks in advance…

@alejito1

Try like this:

              Count = yourStr.Split("world"c).Length 

The above expression will give you no. of times the world word repeated.

1 Like

Thank you the time, how can i put that in uipath studio? Assign activity?

1 Like

@alejito1

Yes, exactly. Here, Count variable is of type Integer.

It doesnt work :frowning: it throws validation error… weird right? you already tried it and worked?

Just split and count will be definitely the wrong answer… you can follow this instead using an execute code activity


Or download CountOcurrences.xaml (5.0 KB) and invoke passing the parameters :slight_smile:

@alejito1

Yes it should work. May I know what error are you getting here ?

Nothing concrete, only there is an error in the form. But dont worry, i could overcome the problem using a foreach and indexof so it finds all the times the word appears… thank you very much though!

1 Like

Hi,

If you want to do the same without for loop, then check this link