InRegex Logo
InRegex
Nuevo

Match American Social Security Number

Explicación

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

Expresión Regular

\\b(?!000|666|9\\d{2})\\d{3}-(?!00)\\d{2}-(?!0000)\\d{4}\\b
Copiar
¿Tienes Comentarios?
python

Ejemplo de Uso

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')
Copiar

Prueba la expresión

Expresiones Regulares Similares