Solved

Regular Expression - international telephone format

Posted on 2008-06-16
4
1,687 Views
Last Modified: 2013-11-26
I have an ASP.net form in which I need to validate an input field for either a North American or international telephone number.  

For the North American format I have:
    ValidationExpression="\d{3}-\d{3}-\d{4}"

How can this be altered so that it accepts either the NA or the international telephone formats?
0
Comment
Question by:cgcmq
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 21795947
what formats do you want to accept for international phone numbers?
the international prefix for north america is +1
0
 
LVL 6

Expert Comment

by:rafayali
ID: 21795967
Umm, I am not an expert on an internal telephone formats, but how can there be any? The reason I say this is because each country has a different scheming. For example, I am originally from a country that uses a two digit city code, along with 7 digit phone numbers. But, there are cities in my native place that have 6 digit numbers.

Clearly, this does not follow the pattern we have in North America (where I am right now).

I believe each country has its own schemes and you cannot generalize an international telephone format, UNLESS THERE IS SUCH A STANDARD ???? I did a search on google for this but it did not reveal that there is such a format, so if there is let me know.

You would have to study each country's telephone format and create a regular expression for that.
0
 

Author Comment

by:cgcmq
ID: 21796203
I found this:
((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext )\d{1,5}){0,1}$

at http://javascript.about.com/library/blre.htm which seems pretty flexible.  
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 21796243
Then since International includes North America, why not just use that?
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

735 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