12,356,784 members (65,294 online)
Rate this:
See more:
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 20:06pm
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.

Rate this:

Solution 1

Try the following:
`\s+\d{1,6}\s+`
It will give you 1234 with the following data :
```1234567
1234
abc1111```
_A_K_ 13-Jul-12 2:12am

Mehdi Gholam 13-Jul-12 2:14am

Thanks AK!
Rate this:

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[^]
Rate this:

Solution 3

[1-9]\d{0,5}

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

Top Experts
Last 24hrsThis month
 OriginalGriff 295 Sergey Alexandrovich Kryukov 238 Richard Deeming 205 Jochen Arndt 195 ErBhati 195
 OriginalGriff 10,073 Sergey Alexandrovich Kryukov 6,739 Dave Kreskowiak 3,317 ppolymorphe 2,467 Karthik Bangalore 2,381