I have tried the above formula and many variations of it, but with no success. I gave it a try, but when I tested the formula it produced an error when I entered the phone number.
You can see an example of this in action below : While this may not look very fun at all, it will validate any valid Social Security Number as per the constraints (and exceptions) listed by the Social Security Administration.666|000|9\d)\d # Don't allow the SSN to begin with 666, 000 or anything between 900-999 - # Explicit dash (separating Area and Group numbers) (?!00)\d # Don't allow the Group Number to be "00" - # Another dash (separating Group and Serial numbers) (?!The United States is not the only country to use Social Security Numbers, but for demonstration purposes we will focus on validating U. This is because on June 25th, 2011, the Social Security Administration revised their assignment process to use a system of randomization that had the following changes : The previously mentioned "randomization act" made it significantly easier to use a mechanism such as a Regular Expression to handle validating Social Security Numbers.Since you no longer would have to worry about the highest group number and area number that had been assigned.Let’s break this one down to see what is going on : ^ # Start of expression (?!2|0) # Don't allow "219-09-999" or "0" explicitly (?!Use your best judgement to determine if this is a viable option for you and your business needs.You can see this expression in action below : If you truly need a reliable method of handling Social Security Number validation, the Social Security Administration offers a service that will properly validate a number for you, however it may not always be free or very quick.In the United States, there are a number of valid formats for phone numbers that might be entered into a form: There are many other variations of this, as well, but those examples should be enough to give you an idea of what we're dealing with here.Because there are so many valid formats, you're going to have to set some rules for reformatting these phone numbers: 1.