fast-replace/go-fast-replace/internal/replace/bm.go

12 lines
287 B
Go
Raw Permalink Normal View History

2023-12-30 21:35:09 +00:00
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)
}