Number of occurrences of a sequence in a string


       NUMAT( <cStringToMatch>, <cString>, [<nIgnore>] ) --> nCount


<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.


The function returns a value that specifies how frequently the <cStringToMatch> sequence was found in the <cString>.


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.


. By implementing SETATLIKE(), wildcard characters can be used within the search expression.


       .  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.


NUMAT() is compatible with CT3’s NUMAT().




Source is numat.c, library is libct.



2 responses to “NUMAT()

  1. Pingback: Harbour String Functions | Viva Clipper !

  2. Pingback: Harbour All Functions – N | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.