strings.Count
Returns the number of non-overlapping instances of the given substring within the given string.
- Syntax
- strings.Count SUBSTR STRING
- Returns
- int
Usage
The strings.Count function returns the number of non-overlapping instances of SUBSTR within STRING. If SUBSTR is an empty string, the function returns 1 plus the number of Unicode code points in STRING.
Examples
{{ "aaabaab" | strings.Count "a" }} → 5
{{ "aaabaab" | strings.Count "aa" }} → 2
{{ "aaabaab" | strings.Count "aaa" }} → 1
{{ "aaabaab" | strings.Count "" }} → 8Last updated:
October 28, 2026
:
content: Apply style guide to strings functions (d6de31ebd)
Improve this page