hugo/docs/content/en/functions/strings.Count.md
2023-05-22 16:47:07 +02:00

586 B

title description categories menu keywords signature relatedfuncs
strings.Count Returns the number of non-overlapping instances of a substring within a string.
functions
docs
parent
functions
count
counting
character count
strings.Count SUBSTR STRING

If SUBSTR is an empty string, this function returns 1 plus the number of Unicode code points in STRING.

Example Result
{{ "aaabaab" | strings.Count "a" }} 5
{{ "aaabaab" | strings.Count "aa" }} 2
{{ "aaabaab" | strings.Count "aaa" }} 1
{{ "aaabaab" | strings.Count "" }} 8