hugo/docs/content/en/functions/strings/Count.md
2023-10-20 09:43:56 +02:00

733 B

title description categories keywords menu function relatedFunctions aliases
strings.Count Returns the number of non-overlapping instances of a substring within a string.
functions
docs
parent
functions
aliases returnType signatures
int
strings.Count SUBSTR STRING
len
strings.Count
strings.CountRunes
strings.CountWords
strings.RuneCount
/functions/strings.count

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

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