4

Possible Duplicate:
How do you implement a good profanity filter?

i need to build a script that remove bad words from someone post or username or anythong else they submit to my site.

i have a small script that already remove them but it also cut good words like: a**, f**k, etc...

now my problem is i have a script that already remove bad words (from my list) but it also remove good one

a** and glass

i do:

str_replace('a**', '***', $message);

i want to make sure i wont strip good words or first name for example, what is the best solution?

thanks

Community
  • 1
  • 1
GuitarMaster
  • 583
  • 3
  • 10
  • 7
    This is a clbuttic mistake. – SLaks Dec 13 '11 at 02:36
  • 4
    See [this thread](http://stackoverflow.com/questions/273516/how-do-you-implement-a-good-profanity-filter). – Raisen Dec 13 '11 at 02:37
  • If you have too, I'd find a class that's already available. In the answer to the question Raisen links to, it looks like there are a couple referenced. – Jared Farrish Dec 13 '11 at 02:40
  • To solve your particular issue, just replace `' ass '` instead of `ass`. But people will still be able to write `a s s` if they want to. Also, note that *ass* can refer to a mammal, a collection of all associated primes or the American Sociological Society. – Dennis Dec 13 '11 at 02:44
  • so ignore the fact that its a bad idea, and do it anyway ! –  Dec 13 '11 at 02:56
  • @Dennis - What about `-ass-`, `.ass.`, `You are such an ass.`? If it's looking for spaces, you're `sc***ed`. – Jared Farrish Dec 13 '11 at 02:58
  • @JaredFarrish: The question was about removing false positives. Just in case it did not show in my first comment: I think that a profanity filter is a horrible feature. – Dennis Dec 13 '11 at 03:02
  • @Dennis - Just reinforcing why it's tilting at windmills. `:D` – Jared Farrish Dec 13 '11 at 03:03
  • @JaredFarrish: Nevermind. I misunderstood the *@Dennis* part... – Dennis Dec 13 '11 at 03:05

0 Answers0