Title |
Test
Find
Pattern Title
|
Expression |
^\$?([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(.[0-9][0-9])?$ |
Description |
Matches currency input with or without commas. |
Matches |
$3,023,123.34 | 9,876,453 | 123456.78 |
Non-Matches |
4,33,234.34 | $1.234 | abc |
Author |
Rating:
Brian Orrell
|
Source |
|
Your Rating |
|
Title: Pattern Title
Name: Jim
Date: 3/13/2007 10:26:44 AM
Comment:
Will not accept 5.5
Title: for US currency
Name: John
Date: 2/15/2007 3:10:34 PM
Comment:
Follow what Rob suggested to get the US currency to work. Once you add the \. it works as desired.
This regex-coach program allows you the enter a reg exp and test it on test input. It has some issues, but it is free.
http://weitz.de/files/regex-coach.exe
Title: Software engineer
Name: Eric Eggers
Date: 11/16/2006 9:36:06 AM
Comment:
I was able to match 0,30. Might work for Europe, but...
Title: decimal chararcter matches anything
Name: Rob
Date: 1/2/2004 2:58:56 PM
Comment:
just a nit but instead of . use \. so you match only the literal instead any one character; at least inside VB/ASP .NET
(subject to your 'local' currency format settings)