Alright so there's the unapproved Advanced Swear Filter, which apparently should have this feature. It doesn't work properly, so copying its' filtering algorithm is out of question.
What I'm trying to do is filter out curse words from a string, as long as they're not whitelisted.
An example:
I blacklisted shit and whitelisted the word 'doshite' (sorry, couldn't think of anything better)
If the user says "If you want to say why in Japanese, you say doshite.", nothing happens.
If they say "Fuck off dipshit", it turns into "Fuck off dip****".
How would you go about this? I have the blacklisted words stored in Array: blacklist and whitelisted words in Array: whitelist.
I'd also like to completely evade the breaking into single words method, as I'll remove the whitespaces before filtering the string anyway.