1
0
Fork 0
hugo/docs/content/en/functions/strings/Replace.md

642 B

title description categories keywords action aliases
strings.Replace Returns a copy of INPUT, replacing all occurrences of OLD with NEW.
aliases related returnType signatures
replace
functions/strings/FindRE
functions/strings/FindRESubmatch
functions/strings/ReplaceRE
string
strings.Replace INPUT OLD NEW [LIMIT]
/functions/replace
{{ $s := "Batman and Robin" }}
{{ replace $s "Robin" "Catwoman" }} → Batman and Catwoman

Limit the number of replacements using the LIMIT argument:

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