hugo/docs/content/en/functions/replace.md
2021-10-31 13:53:55 +01:00

709 B

title description date publishdate lastmod categories menu keywords signature workson hugoversion relatedfuncs deprecated aliases
replace Replaces all occurrences of the search string with the replacement string. 2017-02-01 2017-02-01 2020-09-07
functions
docs
parent
functions
strings.Replace INPUT OLD NEW [LIMIT]
replace INPUT OLD NEW [LIMIT]
false

Replace returns a copy of INPUT with all occurrences of OLD replaced with NEW. The number of replacements can be limited with an optional LIMIT parameter.

`{{ replace "Batman and Robin" "Robin" "Catwoman" }}`
→ "Batman and Catwoman"

{{ replace "aabbaabb" "a" "z" 2 }} → "zzbbaabb"