mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-26 22:04:32 +02:00
Merge commit 'e509cac533600cf4fa8382c9cdab78ddd82db688'
This commit is contained in:
29
docs/content/en/functions/strings/Count.md
Normal file
29
docs/content/en/functions/strings/Count.md
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: strings.Count
|
||||
description: Returns the number of non-overlapping instances of a substring within a string.
|
||||
categories: [functions]
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: functions
|
||||
function:
|
||||
aliases: []
|
||||
returnType: int
|
||||
signatures: [strings.Count SUBSTR STRING]
|
||||
relatedFunctions:
|
||||
- len
|
||||
- strings.Count
|
||||
- strings.CountRunes
|
||||
- strings.CountWords
|
||||
- strings.RuneCount
|
||||
aliases: [/functions/strings.count]
|
||||
---
|
||||
|
||||
If `SUBSTR` is an empty string, this function returns 1 plus the number of Unicode code points in `STRING`.
|
||||
|
||||
```go-html-template
|
||||
{{ "aaabaab" | strings.Count "a" }} → 5
|
||||
{{ "aaabaab" | strings.Count "aa" }} → 2
|
||||
{{ "aaabaab" | strings.Count "aaa" }} → 1
|
||||
{{ "aaabaab" | strings.Count "" }} → 8
|
||||
```
|
Reference in New Issue
Block a user