C# Regex Phone Number

I'm looking for a comprehensive Regex pattern for a north american phone number.  Regex isn't my strong suit so I thought I'd put it up here as I'm sure it's a common problem.  The main thing is that I want to capture anything that resembles a phone number.  It's only used to highlight suspected phone number in text for the user, so false positives are less worrysome than missed numbers...

The following entities should match:
(###)-###-####
(###).###.####
###-###-####
###.###.####
### ### ####
(###) ### ####
### ###-####
### ###.####

etc...

Basically, three number area code (optionally surrounded by parenthesis), with 7 digits following the area code.  Number groups can be delimited by spaces, dashes or dots, and shouldn't need to be consistent.  For example: 604 555-5555 or 604 555.5555 or (604)-555-5555 etc...

Thanks for your help.

sk
tradelineAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
\b(\(\d{3}\)|\d{3})([-.]|\s+)?\d{3}([-.]|\s+)?\d{3}\b
0
dkloeckCommented:
Here is another way:
^(\(\d{3}\)|\d{3})(\.| |\-)\d{3}(\.| |\-)\d{4}$
0
dkloeckCommented:
ozo..at your solution 604 555-5555, as in the solution above, would not work
"shouldn't need to be consistent"
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

ozoCommented:
Sorry, I meant
\b(\(\d{3}\)|\d{3})([-.]|\s+)?\d{3}([-.]|\s+)?\d{4}\b
0
ozoCommented:
(\(\d{3}\)|\b\d{3})([-.]|\s+)?\d{3}([-.]|\s+)?\d{4}\b
0
tradelineAuthor Commented:
Thanks guys, one last thing, in order to match the phonenumber inside of any other given string, I assume that I can add an asterix to the beginning and end of the pattern?

For example, dkloeck's solution: ^(\(\d{3}\)|\d{3})(\.| |\-)\d{3}(\.| |\-)\d{4}$ changes to ??

Gracias.
0
ozoCommented:
(\(\d{3}\)|\b\d{3})(\.| |\-)\d{3}(\.| |\-)\d{4}\b
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.