COUNT Function
Counts the number of times a substring occurs within a string.
Syntax
COUNT(string,substring)
Syntax Elements
string An expression that evaluates to the string to be searched.
substring An expression that evaluates to the substring being counted.
Comments
If substring is not found in string, a value of zero is returned.
If substring is null, the value returned is equal to the length of the string.
Substrings can overlap in the string. For example, substring AA occurs three times in string AAAA.
Note
This behaviour can be modified with the UNIQUE.COUNT compatibility switch option.
Case Insensitivity
If data case insensitive mode is selected (see Case Sensitivity), case is ignored when searching string for substring .
Examples
M = "SMITH, JOHN" X = COUNT(M,"H") PRINT X
Prints 2, because there are two occurrences of the letter H in string M.
A = "714-854-8388" B = "8" C = COUNT(A,B)
Assigns a value of 4 to variable C, because substring B occurs in string A four times.