Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Multiple regex expression

Posted on 2013-01-16
2
Medium Priority
?
506 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
2 Comments
 
LVL 85

Accepted Solution

by:
ozo earned 2000 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Loops Section Overview
Suggested Courses

971 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