TALLY function

Purpose | Count the number of occurrences of specified characters or strings within a string.
Syntax | x& = TALLY(MainString, [ANY] MatchString)
Remarks | MainString is the string expression in which to count characters. MatchString is the string expression to count all occurrences of. If MatchString is not present in MainString, zero is returned. When a match is found, the scan for the next match begins at the position immediately following the prior match.

ANY

If the ANY keyword is included, MatchString specifies a list of single characters to be searched for individually: a match on any one of which will cause the count to be incremented for each occurrence of that character. Note that repeated characters in MatchString will not increase the tally. For example:

X = TALLY("ABCD", ANY "BDB") ' returns 2, not 3

Restrictions | TALLY is case-sensitive, so be wary of capitalization.
See also | INSTR, JOIN$, LCASE$, LTRIM$, MID$, PARSE, PARSE$, PARSECOUNT, REMOVE$, REPLACE, RIGHT$, RTRIM$, TRIM$, UCASE$, VERIFY
Example | ' Returns 1, counting the string "bac" x& = TALLY("abacadabra", "bac") 'returns 8, counting all "b", "a", and "c" characters x& = TALLY("abacadabra", ANY "bac")