A valid phone number is 10 digits, delimited by a dash, and may contain an optional 1-6 digit extension in the format of " x 123456" or " x 123". The following examples would be valid numbers.
123-456-7890 123-456-7890 x 123 123-456-7890 x 1234
The following RegEx works for a 10 digit phone number: /[0-9]{3}-[0-9]{3}-[0-9]{4}/
, however when I attempted to add the optional extension like /[0-9]{3}-[0-9]{3}-[0-9]{4}( x [0-9]{1,6})?/
it broke.
Does anyone know what's wrong?