mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
20 lines
586 B
Markdown
20 lines
586 B
Markdown
---
|
|
title: strings.Count
|
|
description: Returns the number of non-overlapping instances of a substring within a string.
|
|
categories: [functions]
|
|
menu:
|
|
docs:
|
|
parent: functions
|
|
keywords: [count, counting, character count]
|
|
signature: ["strings.Count SUBSTR STRING"]
|
|
relatedfuncs: []
|
|
---
|
|
|
|
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
|