Spaces:
Running on Zero
Running on Zero
File size: 375 Bytes
bc02199 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | """Lightweight anonymization helpers for public mock traces."""
from __future__ import annotations
import re
EMAIL_RE = re.compile(r"[\w.\-+]+@[\w.\-]+\.\w+")
LONG_NUMBER_RE = re.compile(r"\b\d{6,}\b")
def anonymize_text(value: str) -> str:
without_emails = EMAIL_RE.sub("[redacted-email]", value)
return LONG_NUMBER_RE.sub("[redacted-number]", without_emails)
|