A powerful yet infrequently used feature of the regular expression language is the capability to embed conditional processing within an expression. This lesson will explore this topic.
123-456-7890 are both acceptable presentation formats for North American phone numbers.
(123-456-7890 all contain the correct number of digits, but are badly formatted. How could you write a regular expression to match only the acceptable formats and not any others?
This is not a trivial problem; consider this obvious solution:
123-456-7890 (123)456-7890 (123)-456-7890 (123-456-7890 1234567890 123 456 7890