InRegex Logo
InRegex
Neu

Match American Social Security Number

Erklärung

This regex pattern matches American Social Security Numbers. It first uses \b to match word boundaries. Then it uses negative lookahead assertions to exclude invalid SSN patterns like ones starting with 000, 666, or in the 900-999 range. It then matches the standard SSN format of '###-##-####'.

python

Regulärer Ausdruck

\\b(?!000|666|9\\d{2})\\d{3}-(?!00)\\d{2}-(?!0000)\\d{4}\\b
Kopieren
Haben Sie Feedback?
python

Beispielverwendung

import re

ssn_pattern = r'\b(?!000|666|9\d{2})\d{3}-(?!00)\d{2}-(?!0000)\d{4}\b'
ssn = '123-45-6789'
if re.match(ssn_pattern, ssn):
    print('Valid SSN')
Kopieren

Testen Sie den Ausdruck

Ähnliche Reguläre Ausdrücke