Click here to Skip to main content
11,496,146 members (802 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
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 12-Jul-12 21:06pm
Comments
Zoltán Zörgő at 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
  Permalink  
Comments
_A_K_ at 13-Jul-12 2:12am
   
Good Answer! +5!
Mehdi Gholam at 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[^]
  Permalink  
[1-9]\d{0,5}

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

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

  Print Answers RSS
0 Dnyaneshwar@Pune 692
1 RyanDev 230
2 CHill60 163
3 Sascha Lefèvre 145
4 Sergey Alexandrovich Kryukov 124
0 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600


Advertise | Privacy | Mobile
Web02 | 2.8.150520.1 | Last Updated 13 Jul 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100