# What is a valid regex expression for currency?

Hi:

I'm trying to quickly figure out a regex for the following numeric value.

Essentially so it look like a valid currency
- without commas (,)
- or dollar signs (\$)
- greater than 0.00

We have uncovered something like this, but it doesn't seem to work:
([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)

Thanks,
JohnB
LVL 1
###### Who is Participating?

Batchelor, Developer and EE Topic AdvisorCommented:
If we can assume to always have two decimal digits (and hence a decimal point): '^[1-9]\d*\.\d\d|^0.([1-9][0-9]|0[1-9])'
0

Software ConsultantAuthor Commented:
I would like the two (2) decimal digits to be optional.

Thanks,
JB
0

Batchelor, Developer and EE Topic AdvisorCommented:
This will allow no decimal digits and exact two (I don't think 190.1 makes sense):
'^[1-9]\d*(\.\d\d)?|^0.([1-9][0-9]|0[1-9])'
0

Software ConsultantAuthor Commented:
Terrific!

I just extended it to be:    ^[1-9]\d*\.\d\d|^0.([1-9][0-9]|0[1-9])|^[1-9]\d*

Thanks,
JB
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.