If you're looking to filter out generic forms of text, a regex is probably better suited. For a large list of specific text, the following may suit your needs. In either case a hash table should probably be used.
You can loop through every bad word, and compare to input line. This will allow you to match partial words.
alias partialwords {
if (!$hget(badwords)) {
hmake badwords
hload -n badwords badwords.txt
}
var %i = $hget(badwords,0).item
while (%i) {
if ($hget(badwords,%i) isin $1-) return 1
dec %i
}
}