Profanity Filter Guide: Match Rules and Avoiding False Positives

Contents
- Partial Match vs. Exact Match: The Decisive Difference in Matching Rules
- Longest Word First (Greedy Matching)
- The Core Mechanism: Aho-Corasick and the Trie Tree Algorithm
- Comparing the 4 Main Profanity Filtering Approaches
- 5 Common Mistakes When Building a Profanity Filter
- A 5-Step Workflow for Masking Swear Words Without False Positives
- 7 Profanity Filtering Tips from a Service Planner
- Final Decision Tree: Which Matching Option Should You Use?
- Quick Cheat Sheet: Key Terms for Text Censorship & String Matching
- 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.
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.
1. Trie Data Structure and Failure Links
- 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 method | Search speed | False positive rate (Scunthorpe problem) | Blocks disguised swear words | Best fit |
|---|---|---|---|---|
| Simple partial match (basic) | Fast | Very high (mangles normal words) | Low (fooled by special characters) | Censoring simple text notes |
| Word boundary (exact match) | Very fast | Very low (safe) | Moderate (misses attached particles) | English text, standalone words |
| Aho-Corasick + whitelist | Extremely fast (O(N)) | Low (exceptions managed in a dictionary) | Excellent | Large 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
- Replacing short words first: Changing "개" first turns "개새끼" into "***새끼", exposing the broken swear word.
- No whitelist (exception dictionary): Pure Korean nouns like "시발점", "개나리", and "조카" (nephew — also used as slang) get masked.
- Skipping special character/space normalization: Users defeat the filter by putting commas or dots between the letters.
- Poor handling of Korean particles: In exact match mode, "바보" followed by "는/을/를" slips through.
- 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
- Step 1 (Paste the text to censor): Paste your reviews, comments, or chat logs into the tool's input box.
- Step 2 (Choose the matching mode): Pick partial match if you need strict blocking, or exact match if preserving normal words matters more.
- Step 3 (Add custom banned words): Register the insults and brand-specific terms that are unique to your service.
- Step 4 (Set the replacement symbol): Choose your masking style — asterisks (***), [CENSORED], hearts (♥♥), whatever you like.
- 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
- 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.
- 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.
- Ignore letter case (i flag): Turn on the case-insensitive flag to catch mixed-case English profanity like "fUcK" and "ShIt".
- Map leetspeak substitutions: Register a slang dictionary for number swaps such as "1" → "I/ㅣ", "0" → "O/ㅇ", and "8" → "B".
- Update your banned word list regularly: Monitor new coinages and trending derogatory terms, and refresh the dictionary once a month.
- 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.
- 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