Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
/
(?i)(?=(\d)\d)(?<![\d\-\x{2013}\x{2014}%])(?!000|666|9\d\d|\d{3}00|\d{5}0000|\1{9}|012345678|123456789|234567890|098765432|876543210|078051120|219099999)\d{9}(?![\d\-\x{2013}\x{2014}%])(?!\.(?:pdf|docx?|xlsx?|pptx?|zip|jpe?g|png|txt|log)\b)
/
gm
Input 1
################ ## Must match: ################ 009958881 123454891 is my ssn my ssn is 123454891 my ssn is 123454891 ok? my ssn is 123454891. my ssn is:123454891. # This one sneaks though, but we can live with that, maybe? myssnnumberis123454891ok? ################ ## Must not match: ################ # All-Zero group sequences 231840000 231007289 000877289 # Starting with 9 908780485 # Starting with 666 666780485 # Same number sequences: 222222222 555555555 # Ascending/Descending sequences: 123456789 87654321 # Known invalidated SSN: 219099999 078051120 # File names with common extensions: 123454891.pdf 123454891.xlsx Check the attachment: 123454891.xls, then get back to me. Check the attachment: 123454891.jpeg, then get back to me. # Extra digits: 1123454891 1234548911 # Unsupported boundaries: –123454891 —123454891 %123454891 123454891- 123454891— 123454891% 1-123454891 123454891-1 # Valid SSN with separators: 123-45-4891 098-18-6564 123-45-4848 702-02-0202 001-14-0004
Extraction
################ ## Must match: ################ 009958881 123454891 is my ssn my ssn is 123454891 my ssn is 123454891 ok? my ssn is 123454891. my ssn is:123454891. # This one sneaks though, but we can live with that, maybe? myssnnumberis123454891ok? ################ ## Must not match: ################ # All-Zero group sequences 231840000 231007289 000877289 # Starting with 9 908780485 # Starting with 666 666780485 # Same number sequences: 222222222 555555555 # Ascending/Descending sequences: 123456789 87654321 # Known invalidated SSN: 219099999 078051120 # File names with common extensions: 123454891.pdf 123454891.xlsx Check the attachment: 123454891.xls, then get back to me. Check the attachment: 123454891.jpeg, then get back to me. # Extra digits: 1123454891 1234548911 # Unsupported boundaries: –123454891 —123454891 %123454891 123454891- 123454891— 123454891% 1-123454891 123454891-1 # Valid SSN with separators: 123-45-4891 098-18-6564 123-45-4848 702-02-0202 001-14-0004