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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^0$|^[1-9][0-9]*$|^[1-9][0-9]{0,2}(,[0-9]{3})$
Description
I need a pattern to match the whole number / integer (0-99999...), but also allow users to put comma in the thousand positions. This is what I got.
Matches
1234 | 0 | 12,345
Non-Matches
12,3245 | -1 | 1234.23
Author Rating: The rating for this expression. Harry Chou
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: You are right
Name: Harry Chou
Date: 4/5/2005 4:53:30 PM
Comment:
You are right. That's my typo. The expression should be: ^0$|^[1-9][0-9]*$|^[1-9][0-9]{0,2}(,[0-9]{3})*$


Title: Arbitrary length with commas
Name: Gideon Engelberth
Date: 4/5/2005 11:13:29 AM
Comment:
Right now the expression matchs number of arbitrary length as long as they dont have a comma, but only matches one comma group. This could be fixed by changing the end of the pattern to be (,[0-9]{3})*$


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