Click here to Skip to main content
11,410,129 members (60,608 online)

Regular Expressions

QuestionRegular Expression PinmemberMorgSim11-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 PinmemberFiro Atrum Ventus11-Jul-11 23:31 
GeneralRe: Regular Expression PinmemberMorgSim12-Jul-11 0:09 
GeneralRe: Regular Expression PinmemberPIEBALDconsult17-Jul-11 6:55 
AnswerRe: Regular Expression [modified] PinmemberPIEBALDconsult17-Jul-11 8:02 
AnswerRe: Regular Expression PinmemberJimmyRopes13-Aug-11 12:57 
AnswerRe: Regular Expression [modified] PinmemberShahan Ayyub23-Aug-11 12:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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
Web04 | 2.8.150414.5 | Last Updated 2 Mar 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid