Have you tried using $gettok as solitude posted? It matches anything, even if it's not a bad word. I think an alternative should be:
on @*:TEXT:*:#: {
var %x = 1, %y = ass fark sex
while ($numtok(%y,32) >= %x) {
if ($wildtok($strip($1-),$gettok(%y,%x,32),0,32)) {
ban -k $chan $nick 2 No badwords!
}
inc %x
}
}
Actually using $findtok will match exactly the bad words themselves only, so $wildtok is necessary for the script to catch them in a sentence.