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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^[-+]?\d*$
Description
Matches any integer number or numeric string, including positive and negative value characters (+ or -). Also matches empty strings.
Matches
123 | -123 | +123
Non-Matches
abc | 3.14159 | -3.14159
Author Rating: The rating for this expression. Steven Smith
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: Ensure +/- signs are not allowed without a number following
Name: Graham
Date: 11/20/2020 10:16:45 PM
Comment:
To ensure that a number must follow the sign to fix Lindsay's comment ^[-+]?\d+$


Title: Allow alpha chars
Name: Patricio
Date: 2/25/2011 12:56:59 PM
Comment:
This expression allows alpha chars in the first position like "a" or another char.


Title: Doesn't require a number
Name: Lindsay
Date: 9/13/2004 7:07:02 PM
Comment:
This regular expression allows '-' by itself. :(


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