UiPath count word

I have a string “abc def abc”
How to count the occurence of “abc” in the string
Jus t the syntax I need
I forgot the syntax

Hi @Ritaman_Baral

Try this:

yourStringVariable = "abc def abc"
Output = yourStringVariable.Split({"abc"},StringSplitOptions.None).Length - 1

Output is of DataType System.Int32

Regards

grafik

Hi @Ritaman_Baral

The below syntax will also help you get the count

yourStringVariable = "abc def abc"
Output = System.Text.RegularExpressions.Regex.Matches(yourStringVariable, "abc").Count

Output is of DataType System.Int32.

Regards

hey @Ritaman_Baral
try this:
System.Text.RegularExpressions.Regex.Matches(inputString, "abc").Count

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