RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

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: The rating for this expression. Jeff T
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

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.


Copyright © 2001-2025, RegexAdvice.com | ASP.NET Tutorials