A local-first, pattern-driven text-file sanitizer that applies reusable regular expressions one line at a time, writes a cleaned result, separates rejected or affected content, and reports what happened.
Christian Scheller is the Original Concept Creator, author of the initial Perl prototype, and a Co-Developer of DocWasher.
Christian originally described DocWasher as:
- A “text file sanitizer”
- “Inline-Regex bulk applied on a per-line level”
- Including “basic statistics”
- Useful for “Email cleaning”
- Able to “leverage it with a dlp engine”
- Able to load patterns “from a database based on source file type and content tags”
That is the product. The modern project expands the interfaces and safety controls without replacing that model.
DocWasher takes four practical inputs or outputs:
- Source file: The text to inspect.
- Pattern source: Plain regex patterns or a reusable policy pack.
- Clean output: The content that remains after the selected rule behavior.
- Garbage or quarantine output: Rejected lines or original lines affected by sanitization.
It also produces processing statistics.
source file
+ patterns selected for the file type and tags
+ per-line regex processing
├── cleaned output
├── garbage/quarantine output
└── statistics and audit report
Christian’s original material contains two related behaviors.
The Perl code joins all patterns into one regex and processes the source line by line:
- A matching line is written to the destination file.
- A nonmatching line is written to
garbage.txt. - Counts are printed for both groups.
The modern equivalent is:
KeepMatchingLines
This legacy-compatible mode remains tested and preserved.
The accompanying instructions say to place regex in patterns.txt, remove matches from the input, and write the result to the new file.
The modern equivalent is:
RemoveMatchingText
This is the default modern sanitization mode because it matches Christian’s stated “text file sanitizer” intent.
DocWasher preserves both instead of pretending the original code and description said the same thing.
| Mode | Behavior | Connection to Christian’s design |
|---|---|---|
RemoveMatchingText |
Removes matching substrings and retains the rest of each line | Matches the original how-to |
KeepMatchingLines |
Keeps whole lines matching any pattern and sends other lines to garbage | Reproduces the Perl prototype |
RemoveMatchingLines |
Sends matching lines to quarantine and keeps nonmatching lines | DLP and exclusion workflow |
RedactMatchingText |
Replaces matches with a fixed marker | Safe sharing and privacy |
ReplaceMatchingText |
Applies ordered pattern/replacement rules | Normalization and cleanup |
DocWasher reports:
- Input, output, matched, and quarantined line counts
- Total regex matches
- Per-pattern match totals
- Characters removed or replaced
- Source and output sizes
- Best-effort content type
- Processing duration
- Retained and discarded percentages
- Case-sensitivity state
- Processing timestamp
Plain patterns.txt remains a first-class input.
The project now also supports .dwpack.json policy packs containing:
- Pack name and version
- Description and intended use
- File extensions
- Content types
- Content tags
- Processing mode
- Replacement value when needed
- Ordered regex patterns
Policy packs allow DocWasher to select rules based on source-file type and content tags, directly implementing Christian’s database-backed rule-selection idea in a portable, reviewable format.
An email-cleaning policy pack can be selected for .eml, .txt, .csv, or exported mailbox content.
A local or explicitly configured AI can propose regex for:
- Tracking parameters
- Repeated disclaimer blocks
- Known system banners
- Identifiers requiring redaction
- Noise that should be quarantined
AI-generated patterns are proposals. They must be reviewed before execution.
DocWasher includes a DLP wrapper suitable for scripts and pipelines.
It can:
- Select a policy by file type and tags
- Produce a cleaned file
- Produce a quarantine file
- Produce JSON statistics
- Return a nonzero detection exit code when a policy matched content
DocWasher is an integration component, not a certified DLP or compliance product.
pwsh ./src/DocWasher.ps1 `
-SourceFile ./samples/sample-input.txt `
-PatternFile ./samples/patterns.txt `
-OutputFile ./output/cleaned.txt `
-DiscardedFile ./output/affected-original-lines.txt `
-StatisticsFile ./output/statistics.json `
-Mode RemoveMatchingTextpwsh ./src/DocWasher.ps1 `
-SourceFile ./tests/fixtures/legacy-input.txt `
-PatternFile ./tests/fixtures/legacy-patterns.txt `
-OutputFile ./output/kept.txt `
-DiscardedFile ./output/garbage.txt `
-StatisticsFile ./output/statistics.json `
-Mode KeepMatchingLinespwsh ./src/Invoke-DocWasherPolicy.ps1 `
-SourceFile ./samples/sample-email.txt `
-PolicyPack ./policy-packs/email-cleaning.dwpack.json `
-OutputFile ./output/cleaned-email.txt `
-QuarantineFile ./output/email-quarantine.txt `
-StatisticsFile ./output/email-statistics.json `
-ContentTags email,externalpwsh ./src/Invoke-DocWasherDlp.ps1 `
-SourceFile ./samples/sample-input.txt `
-PolicyDirectory ./policy-packs `
-ContentTags pii,external `
-OutputDirectory ./outputExit code 2 means the selected policy matched content.
Generate a reviewable AI prompt without uploading source content:
pwsh ./tools/New-DocWasherAiPolicyPrompt.ps1 `
-Goal "Remove tracking IDs and redact email addresses" `
-FileType ".eml" `
-ContentTags email,external `
-OutputFile ./output/policy-prompt.txtThe prompt asks the AI to return a valid .dwpack.json policy pack.
Source examples are excluded unless they are explicitly provided.
- Source text is processed locally.
- No telemetry is enabled.
- AI integration is optional.
- Raw source content is not sent to an AI by default.
- Regex operations use timeouts in the PowerShell engine.
- Output should be reviewed before sharing or deleting the source.
- Sensitive examples must not be posted in public issues.
Christian’s original Perl prototype is preserved in:
legacy/docwasher.pl
The original usage and historical behavior are documented in:
legacy/howto-original.txt
ORIGIN.md
Original Concept Creator, Author of the Initial Perl Prototype, and Co-Developer
Christian defined the original product model, wrote the initial Perl implementation, and identified the email-cleaning, AI-generated-pattern, DLP, and database-backed policy directions.
Co-Developer and Modernization/Public Project Lead
Clinton reconstructed the project as a tested, documented, local-first public tool; expanded the processing modes; added policy packs, automation, browser and CLI workflows; and led packaging and publication.
MIT License.
Copyright © 2026 Clinton Kosh and Christian Scheller.