In my exercise I'm supposed to validate phone numbers, which of the correct are :
1234567890
123-456-7890
123.456.7890
(123)456-7890
(123) 456-7890
456-7890
I've tried [(]?[0-9][0-9][0-9][).-]? ?[0-9][0-9][0-9][.-]?[0-9][0-9][0-9][0-9]
, but it seems it also accepts something like (123.456-7890
. How I can handle this? Or I should take completely different way ?
Here are some invalid phone numbers:
123-45-6789
123:4567890
123/456-7890