Click here to Skip to main content
12,761,078 members (31,306 online)

Regular Expressions

QuestionRegular Expression Pin
MorgSim11-Jul-11 23:07
memberMorgSim11-Jul-11 23:07 
Hi Guys,
I have three Regex and would like to know if it's possible to combine them into one.
I'm validating phone numbers in the form:
- 0219081234
- 021 908 1234
- 021-908-1234

here are my regex for the above in order:
- var phoneRegex1 = /^(\d{3})(\d{3})(\d{4})$/;
- var phoneRegex2 = /^(\d{3})(\-)(\d{3})(\-)(\d{4})$/;
- var phoneRegex3 = /^(\d{3})(\ )(\d{3})(\ )(\d{4})$/;

Thanks in Advance,
AnswerRe: Regular Expression Pin
Firo Atrum Ventus11-Jul-11 23:31
memberFiro Atrum Ventus11-Jul-11 23:31 
GeneralRe: Regular Expression Pin
MorgSim12-Jul-11 0:09
memberMorgSim12-Jul-11 0:09 
GeneralRe: Regular Expression Pin
PIEBALDconsult17-Jul-11 6:55
memberPIEBALDconsult17-Jul-11 6:55 
AnswerRe: Regular Expression [modified] Pin
PIEBALDconsult17-Jul-11 8:02
memberPIEBALDconsult17-Jul-11 8:02 
AnswerRe: Regular Expression Pin
JimmyRopes13-Aug-11 12:57
memberJimmyRopes13-Aug-11 12:57 
AnswerRe: Regular Expression [modified] Pin
Shahan Ayyub23-Aug-11 12:00
memberShahan Ayyub23-Aug-11 12:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 1 Feb 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid