$Search: Replace substring

Replace string with strings.Replace

https://codeeval.dev/gist/52377c8ecae82200775f0513f3b54f1d

Last argument in strings.Replace is max number of replacements. -1 means "replace all".

Replace string with a regular expression

https://codeeval.dev/gist/5f215605e76da9e4b865fe094d75395b

This shows how to do strings replacements with regular expressions. (?U)or.*al is a non-greedy ((?U) flag) regular expression that matches original string.

We replace all parts of the string matching the regex with a string replaced.

Regular expression is non-greedy, meaning it matches the shortest possible string as opposed to default greedy match which looks for longest possible match.