Click here to Skip to main content
15,900,815 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Team,
I am Little bit confused in Regex.
I have the mobile number textbox.I want regex for Mobile Number. Format of mobile number is
99999 99999
Terms and Condition are as follow:
mobile numbers has 10 numbers.
first number in mobile number must between 1 to 9.
And after that 4 number must be 0 to 9
and after it should be space
and after it should be 5 numbers that is 0 to 9
i have tried this.
JavaScript
var regExpMobileNumber1 = /^\d{5}(1-9)\d{4}\s\d{5}$/;

but its not working..
Kindly tell me where i am getting wrong..
Posted
v2

Try:
JavaScript
var regExpMobileNumber1 = /^[1-9]\d{4,4}\s\d{5,5}$/;
 
Share this answer
 
Comments
[no name] 29-Jan-14 5:54am    
Thanks Buddy..
OriginalGriff 29-Jan-14 5:55am    
You're welcome!
Try the following Regex.

^([1-9]{1})([0-9]{4})\s([0-9]{5})$

So, code would look like...
JavaScript
var regExpMobileNumber1 = /^([1-9]{1})([0-9]{4})\s([0-9]{5})$/;

Demo - http://www.rubular.com/r/O20ouDB62t[^]
 
Share this answer
 
v2
Comments
[no name] 29-Jan-14 5:55am    
Thanks Buddy.
Most Welcome buddy. :)

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