$count
From Scriptwiki
Returns the number of times a substring occurs in a string.
$count(<haystack>,<needle>[,needle2,...,needleN])
Examples
$count returns the total occurances of all needles found in the haystack.
var %haystack = I bought six apples and three pears. I ate one apple and threw the another Apple at Dana. echo -ag I found $count(%haystack,apple) apple(s). echo -ag I found $count(%haystack,pear) pear(s). echo -ag I found $count(%haystack,apple,pear) apple and pear(s). echo -ag I found $countcs(%haystack,Apple) case sensitive Apple(s). echo -ag I found $countcs(%haystack,Pear) case sensitive Pear(s). Result: I found 3 apple(s). I found 1 pear(s). I found 4 apple and pear(s). I found 1 case sensitive Apple(s). I found 0 case sensitive Pear(s).
Note
$countcs is a case sensitive version of $count