package main
import (
"fmt"
"strings"
)
func containsForbidden(text string, forbidden []string) bool {
lower := strings.ToLower(text)
for _, w := range forbidden {
if strings.Contains(lower, w) {
return true
}
}
return false
}
func main() {
text := "This text contains a badword inside"
forbidden := []string{"badword", "evil", "kill", "nasty", "terrible"}
if containsForbidden(text, forbidden) {
fmt.Println("Forbidden word detected")
} else {
fmt.Println("No forbidden words found")
}
}
/*
run:
Forbidden word detected
*/