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:
Hello 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:
first number in mobile number must between 1 to 9
after 5 number it should be space.
i have tried this.
var regExpMobileNumber1 = /^\d{5}(1-9)\d{4}\s\d{5}$/;

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

Thanks
Harshal Raut
Posted

[1-9][0-9]{4}( ){0,1}[0-9]{5}
 
Share this answer
 
v2
Comments
[no name] 29-Jan-14 2:21am    
No sir.i dont want first number to be zero.
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
Kornfeld Eliyahu Peter 29-Jan-14 2:30am    
See updated solution...
[no name] 29-Jan-14 2:44am    
where??
[no name] 29-Jan-14 2:46am    
you mean to say [1-9][0-9]{4}( ){0,1}[0-9]{5}.
Kornfeld Eliyahu Peter 29-Jan-14 2:48am    
Exactly...
try this (tested for grep)
^[0-9]{5} [0-9]{5}$
 
Share this answer
 
Comments
[no name] 29-Jan-14 2:21am    
No sir.i dont want first number to be zero.
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
[no name] 29-Jan-14 3:03am    
Thanks for your reply.
Thanks i got the another answer that is
[1-9][0-9]{4}( ){0,1}[0-9]{5}.

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