The Complete Guide to Regex-Based Text Redaction and PII Sanitization
Regex redaction is the fastest way to strip sensitive patterns from raw text before sharing a document, seeding a database, or processing customer records. This guide explains the mechanics, covers the most useful patterns for real-world PII, and answers the questions that come up most often.
Start by pasting your raw text into the left panel. Then either click a Quick-Insert Preset button to load a standard PII pattern (email, phone, SSN, or credit card), or type your own custom regex directly into the Regex Pattern field. The output panel on the right updates instantly as you type. Use the flag checkboxes to control case sensitivity and multiline behavior. Check the Telemetry bar below the panels to confirm the match count and see how many characters were removed. When the output looks correct, click Copy Sanitized Text or Download .txt to retrieve the cleaned document.
A regular expression (regex) is a sequence of characters that defines a search pattern. The regex engine scans your text from left to right, comparing each position against your pattern. When a portion of the text satisfies all the rules in the pattern, that portion is called a match. You can then replace every match with a fixed string (such as [REDACTED]) or with an empty string to delete it entirely.
For example, the pattern [0-9]{3}-[0-9]{2}-[0-9]{4} matches any text that looks like a US Social Security Number in dashes-separated format: three digits, a hyphen, two digits, a hyphen, then four digits. The engine finds every such sequence in your text and hands each one to the replacement step.
Regex patterns can include literal characters, character classes (like [a-z] for any lowercase letter), quantifiers (like + for one or more), anchors (like \b for a word boundary), and capture groups (parentheses that isolate a sub-match for back-referencing in the replacement string).
Click the Email Address preset button in the Quick-Insert Presets row. This loads the pattern [a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,} into the Regex Pattern field and activates the Global (g) and Case-Insensitive (i) flags automatically.
Paste your text into the Raw Input area. Every string that matches the standard email format (local-part @ domain . tld) is immediately replaced in the right panel with whatever text you have in the Replacement String field (default: [REDACTED]).
If you want to delete the addresses entirely rather than replace them with a placeholder, clear the Replacement String field so it is blank. The telemetry bar will still report how many addresses were found and how many characters were removed, confirming the operation worked.
Yes. The Replacement String field controls what each match is replaced with. The default value is [REDACTED], but you can set it to anything you like, including nothing at all.
To delete matched substrings without leaving a placeholder, simply clear the Replacement String field so it is completely empty. The regex engine will then replace every match with an empty string, effectively removing it from the output while leaving the surrounding text intact.
The Telemetry panel will still report how many matches were found and how many total characters were removed, so you can verify the operation worked as expected even when the output does not show any visible replacement tokens.
Without the global flag, JavaScript's String.prototype.replace() only replaces the first match it finds in the entire string, then stops. With the global (g) flag enabled, the replace operation continues scanning from where the previous match ended and replaces every non-overlapping match in the text.
For content redaction, you almost always want the global flag on, because you need to catch every occurrence of a phone number or email address in the document, not just the first one. This tool enables the global flag by default.
You can toggle it off if you specifically need to replace only the first match for debugging or testing purposes. The Telemetry bar reflects the actual number of replacements made under whichever flag combination you have active, so you can see the difference immediately.
Yes. This tool runs entirely inside your browser. Your text is never sent to AxiomApe servers or any third-party service. The regex evaluation, string replacement, and output rendering all happen in local JavaScript memory on your own device. When you close or reload the tab, all text is discarded.
There are no cookies tracking your input content, no analytics logging what patterns you enter or what text you paste, and no network requests made after the page finishes loading. You can verify this by opening your browser's Network panel in DevTools: you will see zero outbound requests triggered by the tool while you type.
The Privacy Guaranteed badge at the top of the page reflects the same guarantee applied to every tool on AxiomApe: nothing you enter here ever leaves your computer.