PatternCount()
Category: Text
Syntax: PatternCount ( text; searchString ) |
Parameters:
textAny expression that resolves to a text string.
searchStringAny expression that resolves to a text string, representing the substring for which you want to search within the text string.
Data type returned: Number
Description:
Returns the number of times that searchString appears in the text string. PatternCount() returns 0 if the searchString is not found.
Only non-overlapping occurrences of searchString are counted by PatternCount(). PatternCount() is not case sensitive.
Even though PatternCount() is designed to answer the question "how many?", it is often used simply to determine whether one string is contained within another. If it returns any value other than zero, the search string is found.
Examples:
Function | Results |
---|---|
PatternCount ("This is a test"; "is") | Returns 2. |
PatternCount (WindowNames; "¶") + 1 | Returns the number of carriage returns in the list returned by the WindowNames() function. This could be used to determine the number of windows that are available. The ValueCount() function could also be used for this purpose. |
PatternCount ("abababa"; "Aba") | Returns 2. |
Категории