CoolFace
Apppublic

shamiimuhammad/NexGen-Support-Hero

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
guards.py11 linesDownload Raw Back to src
1import re2 3def scrub_sensitive_info(text: str) -> str:4    """Uses Regex logic to mask PII (Personally Identifiable Information)."""5    # Patterns for Email and Credit Cards6    email_regex = r'[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+'7    card_regex = r'\b(?:\d[ -]*?){13,16}\b'8    9    text = re.sub(email_regex, "[EMAIL_HIDDEN]", text)10    text = re.sub(card_regex, "[CARD_HIDDEN]", text)11    return text