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:
November 8, 2026
:
content: Remove categories from front matter (1cc1dd83a)
Improve this page