Profanity Filter Guide: Match Rules and Avoiding False Positives

PublishedToolProfanity Filter & Text Censor

Contents
  1. Partial Match vs. Exact Match: The Decisive Difference in Matching Rules
  2. Longest Word First (Greedy Matching)
  3. The Core Mechanism: Aho-Corasick and the Trie Tree Algorithm
  4. Comparing the 4 Main Profanity Filtering Approaches
  5. 5 Common Mistakes When Building a Profanity Filter
  6. A 5-Step Workflow for Masking Swear Words Without False Positives
  7. 7 Profanity Filtering Tips from a Service Planner
  8. Final Decision Tree: Which Matching Option Should You Use?
  9. Quick Cheat Sheet: Key Terms for Text Censorship & String Matching
  10. Frequently Asked Questions

If you run an online community, a game chat room, or a customer review board, a profanity filtering system that automatically hides the flood of abusive comments and swear words is a must.

But when you apply a simple regular expression or plain word replacement, you run into trouble. Ordinary words like "시발점" (origin, starting point), "개나리" (forsythia), and "바보온달" (the fool Ondal) get starred out as (***) — over-censorship known as the Scunthorpe problem. Or the opposite happens: swear words with a dot (.) or a space slipped between the letters get through completely untouched.

This guide covers it all: the difference between "partial match" and "exact match" (word boundary \b), the Aho-Corasick multi-pattern search algorithm, and text masking that avoids false positives.

Key Takeaways ① Match priority (longest first): Match a longer compound like "개새끼" before a shorter word like "개", or the word gets split and left looking odd. ② Partial match vs. exact match: Partial match stars out the "개" inside "무지개" (rainbow). Exact match only masks standalone words, which cuts false positives. ③ Avoiding the Scunthorpe problem: Run an exception whitelist alongside the filter so legitimate proper nouns and technical terms don't get censored. ④ 100% client-side privacy: This tool never sends your text to an external server. It does real-time regex replacement right inside your browser.

Partial Match vs. Exact Match: The Decisive Difference in Matching Rules

The most important setting in a profanity filter engine is how you define the matching scope:

1. Partial Match

  • How it works: If the banned string appears anywhere in the sentence, it gets detected and masked, no exceptions.
  • Upside: Catches every swear word hidden in context, with nothing slipping by.
  • Downside: Produces false positives, mangling normal words like "개나리", "무지개", and "시발점" into "나리" or "무지".

2. Exact / Whole Word Match

  • How it works: Only detects a standalone word separated on both sides by spaces, periods, commas, or other punctuation, using the regex word boundary (\b).
  • Upside: Completely blocks over-censorship, so ordinary vocabulary never gets unfairly starred out.
  • Downside: Because Korean is an agglutinative language and particles attach directly to the word, forms like "바보가" or "바보를" may not be detected.

Longest Word First (Greedy Matching)

When your filter dictionary contains words of different lengths (say, "개" and "개새끼"), you must sort by character count in descending order and replace the longest words first.

If you replace the short word "개" first, "개새끼" in the sentence turns into "***새끼", and the core of the swear word stays fully visible. That's a critical bug.

Profanity Filter & Text Censor

Free · no install · just paste text to auto-detect profanity and mask it with asterisks in a second


The Core Mechanism: Aho-Corasick and the Trie Tree Algorithm

Let's break down the computer science algorithm that scans thousands of banned words in one millisecond.

  • With a list of tens of thousands of banned words, calling String.replace() for every single word explodes the time complexity to O(N × K) and the server stalls.
  • Aho-Corasick algorithm: Build every banned word into a Trie tree and link it with KMP (Knuth-Morris-Pratt) failure links.
  • It scans the body text just once, achieving O(N + M) linear time complexity, and finds tens of thousands of swear words in 0.001 seconds all at once.

2. The Hangul Unicode Jamo Decomposition Formula

  • The Hangul Unicode decomposition formula that separates the initial, medial, and final consonants: Char Code = 0xAC00 + (Initial × 588) + (Medial × 28) + Final
  • Even if a user mixes in numbers like "ㅅ1ㅂㅏㄹ", Unicode normalization (NFKD) plus a regex that strips non-letter characters (/[^가-힣a-zA-Z]/g) restores the original swear word so it can be detected.

Comparing the 4 Main Profanity Filtering Approaches

Filtering methodSearch speedFalse positive rate (Scunthorpe problem)Blocks disguised swear wordsBest fit
Simple partial match (basic)FastVery high (mangles normal words)Low (fooled by special characters)Censoring simple text notes
Word boundary (exact match)Very fastVery low (safe)Moderate (misses attached particles)English text, standalone words
Aho-Corasick + whitelistExtremely fast (O(N))Low (exceptions managed in a dictionary)ExcellentLarge web communities, game chat
Deep learning AI context analysis (LLM)Slow (heavy compute)Effectively 0% (understands context)Perfect blocking (reads slang)High-touch customer support, legal review

5 Common Mistakes When Building a Profanity Filter

  1. Replacing short words first: Changing "개" first turns "개새끼" into "***새끼", exposing the broken swear word.
  2. No whitelist (exception dictionary): Pure Korean nouns like "시발점", "개나리", and "조카" (nephew — also used as slang) get masked.
  3. Skipping special character/space normalization: Users defeat the filter by putting commas or dots between the letters.
  4. Poor handling of Korean particles: In exact match mode, "바보" followed by "는/을/를" slips through.
  5. Replacement character (*) length mismatch: Turning a four-letter swear word into a single asterisk (*) breaks the rhythm and layout of the original sentence.

A 5-Step Workflow for Masking Swear Words Without False Positives

  1. Step 1 (Paste the text to censor): Paste your reviews, comments, or chat logs into the tool's input box.
  2. Step 2 (Choose the matching mode): Pick partial match if you need strict blocking, or exact match if preserving normal words matters more.
  3. Step 3 (Add custom banned words): Register the insults and brand-specific terms that are unique to your service.
  4. Step 4 (Set the replacement symbol): Choose your masking style — asterisks (***), [CENSORED], hearts (♥♥), whatever you like.
  5. Step 5 (Copy the cleaned text in one click): Copy your clean, safe text in one second and post it in a notice or on your site.

7 Profanity Filtering Tips from a Service Planner

  1. Match the mask to the character count: Replace a three-letter swear word with "***" and a two-letter one with "**" so the sentence still flows naturally.
  2. Normalize repeated characters: For patterns like "씨이이이발", where a vowel is stretched out, compress the run to a single character with the /(.)\1{2,}/g regex before matching.
  3. Ignore letter case (i flag): Turn on the case-insensitive flag to catch mixed-case English profanity like "fUcK" and "ShIt".
  4. Map leetspeak substitutions: Register a slang dictionary for number swaps such as "1" → "I/ㅣ", "0" → "O/ㅇ", and "8" → "B".
  5. Update your banned word list regularly: Monitor new coinages and trending derogatory terms, and refresh the dictionary once a month.
  6. Connect a blacklist based on report counts: Apply an automatic temporary ban rule for users who try to bypass the filter after 3 accumulated reports.
  7. Bookmark this tool: When you screenshot or quote a blog or community post, wipe out sensitive profanity in one second.

Final Decision Tree: Which Matching Option Should You Use?

  • Case A (quoting blog screenshots, cleaning up public agency posts) → Partial match + asterisk (***) masking (thorough cleanup)
  • Case B (a casual community where free conversation matters) → Exact match + whitelist (minimum Scunthorpe false positives)
  • Case C (chat on a children's or education platform) → Partial match + normalization that strips all special characters and spaces
  • Case D (high-volume real-time live stream chat) → Ultra-fast C/WASM module built on Aho-Corasick

Quick Cheat Sheet: Key Terms for Text Censorship & String Matching

  • Scunthorpe Problem: when a banned word's spelling sits inside an ordinary word, so the system blocks an innocent word.
  • Word Boundary (\b): a regex metacharacter that marks the boundary between a letter (alphabet or Hangul) and a space or punctuation mark.
  • Aho-Corasick: a finite automaton algorithm that finds many pattern strings at once with a single scan of the text.
  • Masking: hiding sensitive words or personal information behind symbols such as * or #.

Frequently Asked Questions

Why did the word "무지개" (rainbow) come out as "무지***"?

Because the "Partial match" option is on and "개" (dog) is on your blocklist. That mode masks every matching character inside a word too, so if you only want to mask standalone profanity, switch to the "Whole word" option.

Are swear words with symbols mixed in filtered out automatically?

Default regex matching compares consecutive characters, so to catch profanity with symbols mixed in, it's better to run a second pass: temporarily strip spaces and symbols from the text before you check it.

Is the sensitive text I type sent to a server or stored there?

Not at all. Every regex replacement in this tool runs locally in the JavaScript engine inside your web browser, so your text is never stored on an external server.

This article was adapted from our Korean original. Read the Korean original

Related articles

  1. Base32 Encoding Explained: 5-Bit Conversion, Padding, OTP KeysHow Base32 turns bytes into 5-bit chunks, why 0, 1, 8 and 9 never appear, how = padding works, and how to decode a Google Authenticator secret key.
  2. Base64 Encoding and Decoding: 6-Bit Mapping and Padding RulesSee how Base64 turns 8-bit data into 6-bit characters, why it adds 33% size, how = padding works, and why UTF-8 keeps Hangul and emoji intact.
  3. Base64 to Hex: How 4-Bit and 6-Bit Encoding WorksSee how Hex and Base64 encode the same bytes at 4 and 6 bits, why Hex needs an even length, and how to convert both ways in a second.
  4. bcrypt Hash Generator: 60-Character Structure ExplainedSee how a bcrypt hash is built: version, cost, 22-character salt, and 31-character digest — plus why the same password hashes differently every time.
  5. Brand Name Combiner: Turn Two Words Into Name CandidatesSee how two words turn into 14 brand name candidates with join, hyphen, syllable mix, and suffix rules, plus what the tool does not check.
  6. Business English Email Phrases: Formality Levels ComparedCompare business English email greetings, requests, apologies, and sign-offs by formality, with sentences for Dear vs Hi and Best regards vs Sincerely.

Related tools