Yes... this is known as the "Scunthorpe problem" (look it up on Wikipedia). It's pretty difficult to censor words because they could be contained within other words. And if you only censor it when it has spaces around it then people could add other characters around it, e.g. if I censored "fart" you could post #fart# or xfartx or simply farts.
Also, if you happen to say I AM RACIST in the middle of a sentence then I don't think people will suddenly believe you really are racist.