Regular Expression to find US phone numbers missing Area Code

Hello all,
I have a regular expression that can find US Phone Numbers containing various formatting as shown:
[\(.]?[2-9]\d\d[\).]?[ -]?[2-9]\d\d[-.]\d{4}

results:
(xxx) xxx.xxxx
xxx-xxx-xxxx
xxx xxx xxxx

I'm trying to adjust the regular expression, so that it only finds phone numbers MISSING the area code.  Therefore the phone number in sample text like this would be flagged:

This is a test phone number missing area code: 123-4567.  

The following phone number would not be flagged:

This is a test phone number containing area code: (123) 123-4567.

Thanks in advance.
peerlesslvAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ozoConnect With a Mentor Commented:
^\D*[2-9]\d\d[-.]\d{4}
will return phone numbers that have no numbers before it,
but if you have two phone numbers like
(123) 123-4567.    123-4567
it won't return the second one.
If you need to handle those cases, it may help to know what regular expression implementation you are using, since it could be useful to use some constructs that not all implementation support
0
 
ozoCommented:
^[2-9]\d\d[-.]\d{4}
0
 
peerlesslvAuthor Commented:
thanks ozo, but when i test the regular expression it only captures phone numbers that have no text before it.  This returns ok:
xxx-xxxx

However, this doesn't return when it should:
text text xxx-xxxx.
0
 
peerlesslvAuthor Commented:
Thanks.  This works great.  I'm using the utility PowerGrep.  
0
All Courses

From novice to tech pro — start learning today.