Regular Expression Currency Greater than Zero

I need a regular expression that checks a text box to make sure it's  greater than zero, allows a $ and two places to the right of the decimal.

$0 fails
0 Fails
000000 Fails
0.00 fails

100 Passes
$100 Passes
100.01 passes
.01 passes
Who is Participating?
Terry WoodsConnect With a Mentor IT GuruCommented:
This cut down modification to @FernandoSoto's pattern should give exactly the same result:

Dim pattern As String = "^(?!\$?0)\$?(\d+)?\.?(\d\d)?$"

Open in new window

However, I think it accepts an empty string.

Perhaps this pattern would be better?

Open in new window

Note that it will accept values with a leading zero as long as there is a non-zero digit in the value somewhere.
Fernando SotoRetiredCommented:
Hi whiwex;

Try this pattern out to see if it is what you are looking for.

Dim pattern As String = "^(?!(\$?0{1,}\.?(00)?))\$?(\d+)?\.?(\d\d)?$"

Open in new window

whiwexAuthor Commented:
Thanks it worked great
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.

All Courses

From novice to tech pro — start learning today.