• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 592
  • Last Modified:

cell phone - regex pattern

I am looking a regex pattern for cell phone( sample : 1234567890 or (123)4567890.
0
VBdotnet2005
Asked:
VBdotnet2005
1 Solution
 
Terry WoodsIT GuruCommented:
If it's as simple as those two exact formats, then this pattern will match both:
^(\(\d{3}\)|\d{3})\d{7}$

Open in new window


If you need to vary the number of digits (eg such as an optional extra digit), then you can add flexibility like this:
^(\(\d{3}\)|\d{3})\d{7,8}$

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now