Click here to Skip to main content
11,412,182 members (62,520 online)
Rate this: bad
good
Please Sign up or sign in to vote.
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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Try this regex: ^[0-9]{1,6}$
To test this you can go to below link:
http://www.regular-expressions.info/javascriptexample.html[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

[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 OriginalGriff 348
1 Sascha Lefévre 175
2 ProgramFOX 130
3 Maciej Los 110
4 Sergey Alexandrovich Kryukov 95
0 Sergey Alexandrovich Kryukov 8,980
1 OriginalGriff 7,263
2 Maciej Los 3,500
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web03 | 2.8.150414.5 | 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