Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need the regular expression which matches all positive non decimal integers only range from 0 to 999999. It will not accept any decimal, alphabets or any special character and range should be in between 0 to 999999.
Posted
Comments
Zoltán Zörgő 13-Jul-12 2:13am    
Sorry, but what you men by decimal and non-decimal? Both 0 and 999999 and all numbers between are decimal numbers.

Try the following:
\s+\d{1,6}\s+

It will give you 1234 with the following data :
1234567
1234
abc1111
 
Share this answer
 
Comments
_Amy 13-Jul-12 2:12am    
Good Answer! +5!
Mehdi Gholam 13-Jul-12 2:14am    
Thanks AK!
Try this regex: ^[0-9]{1,6}$
To test this you can go to below link:
http://www.regular-expressions.info/javascriptexample.html[^]
 
Share this answer
 
Comments
Grace Davenport 5-Aug-22 10:36am    
God bless you man
[1-9]\d{0,5}

[1-9] - first digit should not be zero
\d - digit
{0,5} - less than 6 times
 
Share this answer
 

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