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]\d{0,2}(\,\d{3})*|([1-9]\d*))(\.\d{2})?$
Description
Combine Michael Ash's US Dollar amount and Bri Gipson's eliminating zero input to create this RE to accept Optional leading dollar sign, optional well-formed comma separator dollar amount with no zero amount allowed. *** Correction: Remove the "+" otherwise it will incorrectly matches 4 leading digits like 1234,345,678.00 03-03-2005
Matches
$1,234,567.89 | 1234567.89 | $9.99
Non-Matches
$1,2345,67.89 | $1234,345,678.0 | 0
Author Rating: The rating for this expression. Joe Lynwood
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: Correction II
Name: Joe Lynwood
Date: 3/3/2005 11:51:29 PM
Comment:
Just remove all "+", the second "+" is redundant.


Title: Correction
Name: Joe Lynwood
Date: 3/3/2005 11:44:09 PM
Comment:
Just remove the first "+" and it will be OK: ^(\$|)([1-9]\d{0,2}(\,\d{3})*|([1-9]+\d*))(\.\d{2})?$ -- Joe Lynwood


Title: RegEx fails with more than 3 leading digits
Name: Roger PEnce
Date: 2/20/2005 1:09:28 AM
Comment:
This RE incorrectly matches this pattern: 2133,234.34


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