I found this code in some website, and it works perfectly. It validates that the phone number is in one of these formats:
(123) 456-7890 or 123-
Everyone's answers are great, but here's one I think is a bit more comprehensive...
This is written for javascript match use of a single number in a single line:
^(?!.*911.*\d{4})((\+?1[\/ ]?)?(?![\(\. -]?555.*)\( ?[2-9][0-9]{2} ?\) ?|(\+?1[\.\/ -])?[2-9][0-9]{2}[\.\/ -]?)(?!555.?01..)([2-9][0-9]{2})[\.\/ -]?([0-9]{4})$
If you want to match at word boundaries, just change the ^ and $ to \b
I welcome any suggestions, corrections, or criticisms of this solution. As far as I can tell, this matches the NANP format (for USA numbers - I didn't validate other North American countries when creating this), avoids any 911 errors (can't be in the area code or region code), eliminates only those 555 numbers which are actually invalid (region code of 555 followed by 01xx where x = any number).