GDPR-
Here are regex patterns for each category of PII under GDPR. These are general examples and might require fine-tuning based on specific formats and use cases.
1. Direct Identifiers
Name:
- Regex:
\b[A-Z][a-z]+\s[A-Z][a-z]+\b
- Explanation: Matches names with a capitalized first and last name (e.g., "John Doe").
Address (Postal):
- Regex:
(\d{1,5}\s\w+(\s\w+)*,?\s\w+(\s\w+)*,?\s?\w{2}\s?\d{5})
- Explanation: Matches common address formats (e.g., "123 Main Street, Anytown, NY 12345").
Email Address:
- Regex:
\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b
- Explanation: Matches most email addresses (e.g., "[email protected]").
Phone Number:
- Regex:
\+?\d{1,4}[\s.-]?\(?\d{1,3}\)?[\s.-]?\d{1,4}[\s.-]?\d{1,4}[\s.-]?\d{1,9}
- Explanation: Matches international and local phone numbers (e.g., "+1-800-555-1234").
Identification Numbers (e.g., Passport, SSN):
- Regex:
\b[0-9]{3}-[0-9]{2}-[0-9]{4}\b|\b[A-Z]{2}[0-9]{6}\b