I'm making a regex to validate money data, and these are the rules I want: (X will represent numbers)
$ must be at front
.XX -OR- .X is optional for end
. at end NOT valid
1-3 digits left of decimal
infite combinations of XXX, where needed
Examples of valid formats
$xx,xxx.xx
$xxx,xxx,xxx,xxx
$x,xxx,xxx.x
$x.xx
Examples of invalid formats:
$xxxxx
xx,xxx.xx
$xx,xxx.
$xxx,xxx.xxx
Here is what I've got so far, but I know it doesn't work...
I've had several iterations that have had some success, but not total. This is where I am now, and it breaks pretty much on everything...my brain is too tired to backtrack.Code:moneyReg = "^\\$([0-9]{1,3}[,]{1})*([0-9]{1-3})+(\\.[0-9]{1,2})?$";
Thanks in advance!






Bookmarks