Removing whitespaces actually makes it harder. The best way that I can think of is to use regex finding the word that contains "shit" but also include wild cards to get the whole word. Then, you can run that through your whitelist to see if you should block it or not.
regex: \b\w*shit\w*\b
This should return "doshite" which you then run through your whitelist. It no in the whitelist, assume it's a bad word.