
Presidio: Redaction That Beats Your Regex
My hand-rolled patterns caught emails and phones. They missed everything shaped slightly differently.
I wrote my own redaction regexes for an AI assistant. Email addresses, Egyptian phone numbers, card-shaped digit strings. I was pleased with them for about a week.
Then I looked at what was actually reaching the provider. Phone numbers written with spaces. Numbers spelled partly in Arabic digits. An address that no pattern of mine described. A national ID typed with dashes.
My regexes caught the tidy cases and missed everything a real person types.
What Presidio does differently
It combines pattern matching with named-entity recognition, so it identifies things by context rather than only by shape. "Call Ahmed on ..." is recognisable as a phone number even in a format no regex anticipated, and a person's name is detected as a name without a list of every name.
from presidio_analyzer import AnalyzerEngine
from presidio_anonymizer import AnonymizerEngine
results = analyzer.analyze(text=message, language="en")
clean = anonymizer.anonymize(text=message, analyzer_results=results).text
It also handles the anonymisation strategy properly: replace, mask, hash, or encrypt — the last being useful when you need reversibility for a support workflow.
Where it goes in the stack
Between your application and any outbound call. In my LLM proxy it runs on the message before the request leaves, and the redacted text is what gets logged too — so a log export is not a data incident.
Also worth applying to what you store, not only what you send. Support transcripts full of raw personal data are a liability that grows quietly with time.
Arabic and local formats
This is where you must do your own work. Default recognisers are strongest for English and common Western formats. Egyptian mobile numbers, Arabic-script names, Gulf ID formats, and Arabic-Indic digits all need attention.
Presidio supports custom recognisers, so add them for the formats your users actually type, and test with real messages rather than invented examples.
Be honest about the limits
No redaction is complete. Someone will phrase something in a way nothing catches, and this is defence in depth rather than a guarantee. It reduces exposure substantially; it does not eliminate it.
Which means it does not replace the other decisions: minimise what you send, keep retention short, and be clear with users about what leaves your systems.
Resources
- Repo: data-privacy-stack/presidio
- Docs: microsoft.github.io/presidio
- Video walkthroughs: YouTube: Presidio PII anonymization
- Where it plugs in: Never put your API key in the browser
Need this built properly?
I build secure, fast, bilingual platforms for clients across Egypt, Saudi Arabia, the UAE and Kuwait.


