NUMAT()
Number of occurrences of a sequence in a string
Syntax
NUMAT( <cStringToMatch>, <cString>, [<nIgnore>] ) --> nCount
Arguments
<cStringToMatch> The search string. <cString> The string to search.
<nIgnore> The number of characters that are excluded from the search. The default value ignores none.
Returns
The function returns a value that specifies how frequently the <cStringToMatch> sequence was found in the <cString>.
Description
NUMAT() determines how often a particular <cStringToMatch> appears within <cString>. When you use <nIgnore> you can lock out a number of characters at the beginning of the <cString> and keep them out of the search. The setting for CSETATMUPA() impacts your results. The character string is searched from the left for each occurrence of the <cStringToMatch> string. If CSETATMUPA() is .F., then the search continues after the last character of the found sequence. If CSETATMUPA() is .T., then the search continues after the first character of the found sequence.
Note
. By implementing SETATLIKE(), wildcard characters can be used within the search expression.
Examples
. Count from the first position: ? NUMAT("ab", "abcdeabc") // Result: 2 . Count from the second position. <nIgnore> specifies that one space is to be skipped: ? NUMAT("ab", "abcdeabc", 1) // Result: 1 . This example shows the impact of CSETATMUPA() when counting the string "aa" within the <cString> string: CSETATMUPA(.F.) // Off ? NUMAT("aa", "aaaab") // Result: 2 CSETATMUPA(.T.) // On ? NUMAT("aa", "aaaab") // Result: 3 . Examples for the use of SETATLIKE() can be found under the corresponding function description.
Compliance
NUMAT() is compatible with CT3’s NUMAT().
Platforms
All
Files
Source is numat.c, library is libct.
Seealso
CSETATMUPA(), SETATLIKE()