From algorithmic point of view most forums use something like checking against word-list, maybe regular expressions. You may look into e.g. open-source forum engines. And if there will be some code, hard to understand, asking about code here would be good question.
Anylisys of people's language is very hard task, not to say about determining, whether word is "bad". To whom? It's not an algorithm one may think out in 10-15 minutes and suggest here.
PS: I was an administrator on (vBulletin) forum with over 100k registrations for several years. There was word filter, but it'd be nothing w/o manual moderators' work.