I have a situation where I need to validate social security numbers, and they can be input in any of the three following formats:
123-45-6789 123/45/6789 123456789
I tried writing a regular expression to match these, and came up with this:
^[0-9]{3}(-|/)?[0-9]{2}(-|/)?[0-9]{4}$
which is close, but it still allows strings like 123-45/6789
through, which I would like to prevent. Is there any way to match the delimiters such that all hypens are allowed, and all forward slashes are allowed, but not a combination of the two?