Regular Expression Exercise S1

The first in a series of exercises designed to teach you more about regular expressions, written by a guy who got partway through writing a regex book.

But first, a word about tools. It's a lot easier to use a tool to do this sort of thing than it is to write code to do it. So, I suggest one of the following:

So, S stands for simple, 1 stands for 1, so this first one is going to be pretty simple.

S1 - Match a Social Security Number

Verify that a string is a social security number of the format ddd-dd-dddd.

 

Answer and explanation to follow.