Skip to content

Instantly share code, notes, and snippets.

@tenox7
Created January 11, 2025 21:52
Show Gist options
  • Save tenox7/4a68c3aeeca26039e65abb96ee23817c to your computer and use it in GitHub Desktop.
Save tenox7/4a68c3aeeca26039e65abb96ee23817c to your computer and use it in GitHub Desktop.
Replace all characters with something
func replaceChars(str, repl, with string) string {
var oldnew []string
for _, char := range repl {
oldnew = append(oldnew, string(char), with)
}
return strings.NewReplacer(oldnew...).Replace(str)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment