regex for ssn
match a social security number
^(?!0{3})(?!6{3})[0-8]\d{2}-(?!0{2})\d{2}-(?!0{4})\d{4}$
Regex Flags
global match
?
ignore case
?
multiline
?
dotAll
?
unicode
?
sticky
?
123-45-6789
123 45 6789
333-22-4444
aaa-bbb-cccc
900-58-4564
999-58-4564
000-45-5454
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 |
---|---|
/\d/ | matches any digit |
/(hello){1,3}/ | matches "hello" that occur between 1 and 3 times (inclusive) |
/^/ | matches beginning of a line |
/$/ | matches end of a line |
iHateRegex
by
geon