Can you provide an example of a regex pattern used to detect Social Security Numbers (SSNs), ensuring that SSNs are identified and protected from unauthorized access or sharing?
Provide an example of a regex pattern used to detect Social Security Numbers (SSNs).
Share
To detect Social Security Numbers (SSNs) while ensuring their protection, a common regex pattern can be:
b(?!000|666|9d{2})(?!00)d{3}-(?!00)d{2}-(?!0000)d{4}b
This regex pattern matches the standard format of SSNs in the United States (XXX-XX-XXXX) while excluding specific invalid combinations. Ensure proper data security measures are implemented to handle SSNs responsibly.