Totally open for suggestion on how to fix this - right now I'm using regex and a list of "profane" words, so nothing too fancy. But I'm interested in looking into solutions for this problem.
Could be interesting to include an optional argument callback that would receive the part of the string that's being censored and returns a string to replace that part of the word with - so that you can conditionally prevent censorship or censor it with something else than *.