How can I use a regext to filter out a list of blacklisted(Obscene) words, such that if a black listed words is like \'Bill Joseph\'
Then \'I am Bill Josephine
Simple, and this works:
String badStrRegex = "\\WBill Joseph\\W?"; Pattern pattern = Pattern.compile(badStrRegex); Matcher m = pattern.matcher(testStr); //testStr is your string under test boolean isBad = m.find();
It works!! Tested against all your input.