12 lines
287 B
Go
12 lines
287 B
Go
|
package replace
|
||
|
|
||
|
import "strings"
|
||
|
|
||
|
// Uses strings.NewReplacer (which implements Boyer-Moore search)
|
||
|
// See https://go.dev/src/strings/search.go
|
||
|
func BoyerMooreReplace(corpus string, pairs []string) string {
|
||
|
replacer := strings.NewReplacer(pairs...)
|
||
|
|
||
|
return replacer.Replace(corpus)
|
||
|
}
|