NUMAT() Counts the number of occurrences of a sequence within a string ------------------------------------------------------------------------------ Syntax NUMAT(<cSearchFor>,<cString>,[<nIgnore>]) --> nNumber Arguments <cSearchFor> Designates the search string. <cString> Designates the string to search. <nIgnore> Designates 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 <cSearchFor> sequence was found in the <cString>. Description NUMAT() determines how often a particular <cSearchFor> 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 <cSearchFor> 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.
See Also: CSETATMUPA() SETATLIKE()