Solved

Multiple regex expression

Posted on 2013-01-16
2
502 Views
Last Modified: 2013-01-16
Hi,

I have a c# asp.net mvc 3 application.

I have a phone number that current has a regex of this:

^[2-9]\d{2}-\d{3}-\d{4}$

which is ###-###-####

I need to add another phone number format like this:

(+### #) #######

What is the best way to approach this? Is there a multiple regex or a conditional reg ex I can use?  Can I put an OR in the reg ex? What would be the new reg ex format?

Thanks...
0
Comment
Question by:michael1174
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 38782134
^([2-9]\d{2}-\d{3}-\d{4}|\(\+\d{3} \d\) \d{7})$
0
 
LVL 2

Author Closing Comment

by:michael1174
ID: 38782278
Looks like it works, thank you very much.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert VB web project to C# 3 62
asp.net repeater server posting 5 35
Pdf not loading 2 37
How to get the range for the percentage from user input. 4 20
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question