Geekpedia Programming Tutorials






Regular expression for validating phone numbers

On Tuesday, October 2nd 2007 at 10:46 PM
By Andrew Pociu (View Profile)
***--   (Rated 2.5 with 2 votes)
Advertisement
The following regular expression will validate phone numbers in all well known formats, such as:

555-12-34
555 12 34
555 1234
555 12-34
5551234
(012) 555-12-34
(012) 555 1234
+1 (012) 555-12-34
+1 (012) 5551234


...and many other similar formats.

/^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/
Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this Knowledge Base article
Comment Current Comments
by piapeti on Wednesday, December 16th 2009 at 05:49 AM

this regular expression is fine

by piapeti on Wednesday, December 16th 2009 at 05:55 AM

this regular expression is fine


Comment Comment on this Knowledge Base article
Name: Email:
Message:
Knowledge Base Related Knowledge Base Articles
There are no related KB articles.

Comment Related Source Code
There is no related code.

Comment Related Tutorials
There are no related tutorials.

Jobs Regex Job Search
My skills include:

Enter a City:

Select a State:


Advanced Search >>
Latest Tech Bargains

Advertisement

Free Magazine Subscriptions

Today's Pictures

Today's Video

Other Resources

Latest Download

Latest Icons