Click here to Skip to main content
15,908,455 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
need a regular expression for phone no that accept numbers and '-',it must start with a number.
currently am using this @"/^\d{10}$/" but its not working fine.
Posted
Comments
Neetin_1809 7-Aug-14 8:54am    
Are you using with asp.net or desktop based applications? Give Some example which it should accepts and which it does not accept .
Nainaaa 8-Aug-14 5:53am    
desktop app,it should accept 33333,55-34242-24242-22,3-13131-133113 etc it should accept numbers and -,
it should not accept the -222111,33333-,4444---2222,33--11 etc

CSS
Hi, please refer for you solution, may be it helps :

http://stackoverflow.com/questions/123559/a-comprehensive-regex-for-phone-number-validation


One more link for you help :

http://stackoverflow.com/questions/16699007/regular-expression-to-match-standard-10-digit-phone-number
 
Share this answer
 
Try this:-
/^[0-9]\d{2,4}-\d{6,8}$/
 
Share this answer
 
Hi

try using this:-
^(?:\([2-9]\d{2}\)\ ?|[2-9]\d{2}(?:\-?|\ ?))[2-9]\d{2}[- ]?\d{4}$

Matches
5305551212
(530) 555-1212
530-555-1212

refer For More[^]
Regular Expression Library[^]

hope this helps
 
Share this answer
 
Comments
Richard MacCutchan 7-Aug-14 7:37am    
+5, I'm always impressed with people who can write REs like the above.
Karthik Harve 7-Aug-14 7:48am    
Thanks Richard :)
Raul Iloc 7-Aug-14 7:42am    
You have my vote (5).
Karthik Harve 7-Aug-14 7:48am    
Thanks Raul :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900