Count characters

i have used switch condition to check in paragarah(text) whether it contains “Total” or not.If it contains Total then how many times, if its 4 times then ok otherwise wait
so , i have used for each in text->switch item.toString.contains(“TOTAL”)->log message saying YES,(yes is coming 3 times) then item.tostring.contains(“TOTAL”).count
im getting wrong value ie 5

@Ananya1 Refer this link to get total number of count in the string

Im getting 0 in output
System.Text.RegularExpressions.Regex.Matches(item.ToString,“TOTAL”).Count

@Ananya1 Don’t use this inside the foreach loop

item inside foreach

Try like this (and note that you need a valid expression, not just the word you need to find):
System.Text.RegularExpressions.Regex.Matches(item.ToString,"\W*((?i)total(?-i))\W*").Count