hugo/docs/content/en/functions/replace.md
2022-12-02 09:19:23 +01:00

731 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
replace
replace INPUT OLD NEW [LIMIT]
strings.Replace INPUT OLD NEW [LIMIT]
replaceRE
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"