A sensitive word filter service based on DFA
go get -u -v github.com/killtw/lemonade
package main
import (
"fmt"
"github.com/killtw/lemonade/lemonade"
"log"
)
func main() {
if err := lemonade.InitTrie(); err != nil {
log.Fatalln(err)
}
lemonade.Add("test")
f1, m1 := lemonade.Replace("123test321")
fmt.Printf("filtered: %s, matches: %s\n", f1, m1)
f2, m2 := lemonade.Replace("123te!@#$%st321")
fmt.Printf("filtered: %s, matches: %s\n", f2, m2)
}
filtered: 123****321, matches: [test]
filtered: 123*********321, matches: [te!@#$%st]
The MIT License (MIT). Please see License File for more information.