def const dash pure containsCount(haystack: text, needle: text): number
Returns the number of non-overlapping occurrences of the needle within the haystack.
haystack: the full text.
needle: the text to search within haystack.
Examples
haystack = "Hello World!"
show table "Contains count" with
containsCount(haystack, "l") as "Count of 'l'"
containsCount(haystack, "World") as "Count of 'World'"
Output:
Count of ’l'
Count of ‘World’
3
1
Errors
Needle is an empty string.
The needle cannot be an empty text value.
Remarks
This function is case-sensitive.
This function is usable in const and dash contexts.
Recipes and best practices
This function should not be used to get the number of fields in a text containing separators. Use fieldCount instead.