Title |
Test
Find
Pattern Title
|
Expression |
^[1-9][0-9]{0,2}$ |
Description |
All positive non-zero integers between 1 and 999. You can adjust the upper range of this expression by changing the second number (ie 2) in the {0,2} part of the expression. |
Matches |
1 | 561 | 999 |
Non-Matches |
-1 | 0 | 1000 |
Author |
Rating:
Jeff T
|
Source |
|
Your Rating |
|
Title: RE: Some more tweaking needed
Name: Jeff Tolle
Date: 1/21/2005 1:00:26 PM
Comment:
Giblet,
Not sure if that matters for most purposes. We are just trying to use the RegEx for validation on some .Net controls. So if putting a '0' in front of the number stops the user from going forward, then all they have to do is remove the '0'.
In other words, it is OK for it to be too restrictive when another, equally correct and equivalent response will suffice.
Title: Some more tweaking needed
Name: Giblet
Date: 1/20/2005 10:25:22 AM
Comment:
When you have a leading zero (like 01 or 001) it doesn't match
Title: Suits Me...
Name: Shina O.
Date: 10/22/2004 3:12:22 AM
Comment:
Thanks for the RE. Suits my puprose, but with a little tweaking.
Title: Edited to correct for error
Name: Jeff Tolle
Date: 10/19/2004 8:24:29 AM
Comment:
Thanks John. Tweaked to address your error on 10/19/04
Title: Almost, but needs tweaking
Name: John Sturgeon
Date: 10/18/2004 10:40:20 AM
Comment:
One problem with this is that the control mechanism only works if you have '0' in the the string. For example, the regex as written will not match 1000 or 1001 or 1011, etc., but WILL match 1111.