Skip to main content
Regexflux

US Social Security Number

intermediate

Matches US SSN in XXX-XX-XXXX format with basic area number validation.

ssnsocial-securityusidentifier

Pattern

/(?!000|666|9\d{2})\d{3}-(?!00)\d{2}-(?!0000)\d{4}/g

Try It

0 of 7 strings matched

Explanation

Matches SSN format with negative lookaheads to reject invalid area numbers (000, 666, 900-999), group numbers (00), and serial numbers (0000) per SSA rules.

Test Strings

Matching

  • 123-45-6789
  • 001-01-0001
  • 899-99-9999

Non-matching

  • 000-12-3456
  • 666-12-3456
  • 123-00-3456
  • 123-45-0000

Language Compatibility

LanguageSupport
JSFull support
PYTHONFull support
JAVAFull support
PHPFull support
GONot supported (RE2 engine)

Code Snippets

const regex = /(?!000|666|9\d{2})\d{3}-(?!00)\d{2}-(?!0000)\d{4}/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);

Common Variations

Without hyphens

(?!000|666|9\d{2})\d{3}(?!00)\d{2}(?!0000)\d{4}

Matches SSN without separators