DataBasic Reference > Statements and Intrinsic Functions > C > COUNTS Function

Comment on this topic

Documentation Comments

Use this form to comment on this topic. You can also provide any general observations about the Online Documentation, or request that additional information be added in a future release.

Reality V15.0 ()

COUNTS Function (DataBasic) (m618703+counts_f.htm)

To

Reality

Version

Topic

Submitted by

Company

Location

Email address

Comment

 

 

COUNTS Function

Counts the number of times a substring occurs in each element of a dynamic array.

Syntax

COUNTS(dynArray, substring)

Syntax Elements

dynArray A DataBasic expression that evaluates to a dynamic array.

substring A DataBasic expression that evaluates to a string.

Return Value

A dynamic array with the same structure as dynArray, but with each element replaced by the number of times substring occurs in that element.

If substring is null, each element is replaced by its length in characters.

Substrings can overlap; for example, substring AA occurs three times in string AAAA.

Note: This behaviour can be modified with the UNIQUE.COUNT compatibility switch option.

Example

ARY = "MMI":@AM:"MCMLXXXVII":@AM:"MCMXCVIII"
NEWARY = COUNTS(ARY, "II")

Sets NEWARY to "0AM1AM2". The third element is 2 because COUNTS matches the overlapping elements.

RealityV15.0Comment on this topic