• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 587
  • 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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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