Profanity Filter using a Regular Expression (list of 100 words)
What is the correct way to strip profane words from a string given: 1) I have a list of 100 words to look for in an array of strings. 2) What is the correct way to handle partial words? How do most people handle this? For example the word mass. Then sometimes a partial word is also bad - assume foobar is an extremely profane word I may want to disallow foobar and foobar* and *foobar. So do you put all the words into a single expression or loop through the list? What's the right way to tackle it? I'm using Groovy/Grails but any modern languages examples welcome. This is quite a difficult