regex for ssn

match a social security number

A Social Security number (SSN) is a nine-digit number that the U.S. government issues to all U.S. citizens and eligible U.S

This expression can be used to find or validate a hyphen-separated Social Security Number (SSN) in the format NNN-NN-NNNN.

An SSN cannot:

  • Contain all zeroes in any specific group (e.g 000-##-####, ###-00-####, or ###-##-0000)
  • Begin with 666.
  • Begin with any value from 900-999.

Cheatsheet

expr usage
iHateRegex
by geon