diff --git a/profanity-filter.js b/profanity-filter.js index f6ecba3..7caf349 100644 --- a/profanity-filter.js +++ b/profanity-filter.js @@ -394,7 +394,12 @@ class ProfanityFilter { */ filterProfanity(text, replacement = '*') { const analysis = this.analyzeProfanity(text); - return analysis.filtered; + let filteredText = text; + for (const match of analysis.matches) { + const regex = new RegExp(`\\b${match.word}\\b`, 'gi'); + filteredText = filteredText.replace(regex, replacement.repeat(match.word.length)); + } + return filteredText; } /**