- The first Regular Expression Library on the Web!

Please support RegExLib Sponsors


Regular Expression Details

Title Test Find Pattern Title
Allows only positive integers that are greater then 0. Easily modified for +/- intergers and allowing zero.
1 | 12 | 124
-1 | a | 1.0
Author Rating: The rating for this expression. William Powell
Source Me
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: Integers: a few regex
Name: |ON|
Date: 11/19/2014 10:40:11 AM
If you only want non-zero positive integers without zero-padding: without plus-sign: [1-9][0-9]* with optional plus-sign: \+?[1-9][0-9]* with mandatory plus-sign: \+[1-9][0-9]* If you want to allow all positive integers, incl. zero. without plus-sign: 0|[1-9][0-9]* without plus-sign before zero: 0|\+?[1-9][0-9]* with optional plus-sign: \+?(0|[1-9][0-9]*) with mandatory plus-sign: \+(0|[1-9][0-9]*) If you want to allow all non-zero integers: without plus-sign: -?[1-9][0-9]* with optional plus-sign: [+-]?[1-9][0-9]* with mandatory sign: [+-][1-9][0-9]* If you want to allow all integers including zero (without sign before zero) : without plus-sign: 0|-?[1-9][0-9] with optional sign: 0|[+-]?[1-9][0-9]* with mandatory sign: 0|[+-][1-9][0-9]* If you want to allow zero-padding, here are some possibilities: 0*[1-9][0-9]* [+-]?0*[1-9][0-9]* 0+|[+-]?0*[1-9][0-9]*

Title: Pattern Title
Name: Mike
Date: 6/19/2006 5:30:22 PM
0 is positive right? ^[0-9]+$ is really what you need

Title: thank you
Name: daniele
Date: 5/18/2004 10:33:39 AM
thank you! :-)

Title: Good call...
Name: William Powell
Date: 9/23/2003 8:43:04 PM
You were absolutely correct. Changed to be correct.

Title: error
Name: Jason Galvin
Date: 9/23/2003 8:01:43 PM
Please correct me if I'm wrong, but according to the description this expression should match "89011", but it doesn't, apparently because this positive integer contains the character zero.

Copyright © 2001-2019, | ASP.NET Tutorials