badwords
badwords copied to clipboard
Improve split regrex
Add support to clean words with character _
before: console.log(filter.clean("Don't be an ash0le_word")); //Don't be an ash0le_word
after: console.log(filter.clean("Don't be an ash0le_word")); //Don't be an ******word
Unfortunately, this breaks when you have something like this:
clean("_a_s_s_h_o_l_e_")
// "_asshole"
Thinking more about it, I'm not sure it's possible to have a "correct" rule in this case. In some cases, we want the _ character treated as a word break, while in others we want it treated as if it didn't exist. Once you start getting into phrases that combine the two, all bets are off
the easiest way I think would be to omit all symbols. word.replace(/[^a-zA-Z]/g, "")