So I have to write a regular expression that will match US phone numbers, which can be of the form x-xxx-xxx-xxxx
or xxx-xxx-xxxx
or (xxx)xxx-xxxx
or xxx-xxxx
. I am not sure if what I have will work though, cause I am unable to test it. Would what I have below work or is there a simpler expression?
grep '+?(1[ -])?((\d{3})[ -]|(\d{3}[ -]?)){2}\d{4}'