Can someone provide me a regex for SSN that matches either
123-45-6789
OR
XXX-XX-XXXX
I currently have ^\\d{3}-?\\d{2}-?\\d{4}$
To strictly answer you question:
^(123-45-6789|XXX-XX-XXXX)$
shoud work. ;-)
If you read the section "Valid SSNs" on Wikipedia`s SSN article then it becomes clear that a regex for SSN validation is a bit more complicated.
Accordingly a little bit more accurate pure SSN regex would look like this:
^(?!(000|666|9))\d{3}-(?!00)\d{2}-(?!0000)\d{4}$