Gopher
FUNCTIONS

replaceRE

Replaces all occurrences of a regular expression with the replacement pattern.

Syntax

strings.ReplaceRE PATTERN REPLACEMENT INPUT [LIMIT]
replaceRE PATTERN REPLACEMENT INPUT [LIMIT]

strings.ReplaceRE returns a copy of INPUT, replacing all matches of the regular expression PATTERN with the replacement text REPLACEMENT. The number of replacements can be limited with an optional LIMIT parameter.

{{ replaceRE "^https?://([^/]+).*" "$1" "http://gohugo.io/docs" }}` → "gohugo.io"
{{ "http://gohugo.io/docs" | replaceRE "^https?://([^/]+).*" "$1" }}` → "gohugo.io"
{{ replaceRE "a+b" "X" "aabbaabbab" 1 }} → "Xbaabbab"