- The first Regular Expression Library on the Web!

Please support RegExLib Sponsors


Regular Expression Details

Title Test Find Pattern Title
This Expression checks if the value is an integer, positive, not zero and not a decimal. Very handy for use when people need to fill in whole numbers, like when ordering car parts on a website (you dont want your customers to order -10 tires or 0.7 mirrors..
1 | 00000428123 | 1230000
0 | 00000000 | any text or +, - or any other character
Author Rating: The rating for this expression. Dennis de Jong
Your Rating
Bad Good

Enter New 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: defect for some case
Name: Trupti
Date: 11/15/2010 3:39:49 AM
Hey its not working for input 03500 because you have restricted it bye the logic:::if it starts with 0-9 then can only combine with 1-9. I think below regEx wich is modification of the regEx by Dennis de Jong .Just try it. ^[0-9]*[1-9]+$|^[0-9]+[1-9]+[0]+$|^[1-9]+[0-9]*$

Title: Not works!
Name: anonymous
Date: 6/20/2010 1:57:49 PM
with values 00010, 00020, 00030, ..., 00100, 00200, 00300, ...

Title: Try this one that matches leading and trailing 0s
Name: Skeeter
Date: 4/8/2005 1:15:30 PM
^(?=.*[1-9].*$)\d{0,6}?$ Allows leading and trailing 0s. Must have at least 1 non-0 digit. Change \d{0,6} to alter the match length of the value.

Title: leading and trailing 0s
Name: Julie C
Date: 4/5/2005 1:48:45 PM
Ditto on the previous comment. 000123 matches. 123000 matches. 000123000 does not match. Is this the desired behavior?

Title: 05890 not a valid integer?
Name: jq31
Date: 4/3/2005 10:47:15 AM
It does not validate the number 05890 as a correct integer.

Copyright © 2001-2018, | ASP.NET Tutorials