StrCnt

Counts the occurrences of a substring within a string.

Syntax:

StrCnt(string, sub-string, start-pos, end-pos, flags)

Parameters:

(s) string specifies the main string.

(s) sub-string specifies the substring to search for within "string".

(i) start-pos specifies the position in "string" at which to begin searching, or -1 to indicate the end of the string. The first character of the string is at position 1.

(i) end-pos specifies the position in "string" at which to end searching, or -1 to indicate the end of the string. The first character of the string is at position 1. Note that if the string begins at or before "end-pos" and continues past "end-pos", it will be counted.

(i) flags can be set to 0, or can specify one or more of the following values combined with the bitwise OR ('|') operator:

Value
    Meaning
1        match case

Returns:

(i) count number of occurrences.

 

Example:

str = "How many I's are in this string?"
rslt = StrCnt(str, "i", 1, -1, 0)
Message("STRCNT - number of occurrences of the letter i", rslt)

See Also:

StriCmp, StrIndex, StrInsert, StrLen, StrOverlay, StrScan, StrSub