• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1380
  • Last Modified:

Regular Expression to validate a currency of $50 or greater

I need a regular expression that will validate a value to check if it is $50 US or greater.  It should allow 2 decimal places and a comma for a thousands separator.
0
tracymr
Asked:
tracymr
1 Solution
 
ddrudikCommented:
Be as specific as possible with your request, specifically decimal, decimal places, and what of those are required/optional.
0
 
ozoCommented:
\$?\b(?=\d{1,3}(,?\d{3})*(\.\d\d)?\b)[5-9]\d|[1-9][\d,]{2}
0
 
tracymrAuthor Commented:
OK.. specifics.

I need to validate that an entry is greater than or equal to 50.00
no dollar sign
up to 2 decimal places but not required.
comma can be used as a thousands delimeter, but not required

Acceptable values would be:
50
50.00
50.01
50.1
1,000
1000.00
1000

Not acceptible:
any number less than 50
50.000 (non US version of $50,000) and only 2 decimal places

Is this better descriptively?

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
tracymrAuthor Commented:
ozo,

I tried out your solution and it allows numbers less than 50 such as 4.99.

0
 
ozoCommented:
^\$?\b(?=\d{1,3}(,?\d{3})*(\.\d\d)?\b)[5-9]\d|[1-9][\d,]{2}
0
 
ozoCommented:
to match 50.1 you probably want
^\$?(?=\d{1,3}(,?\d{3})*(\.\d\d?)?$)[5-9]\d|[1-9][\d,]{2}
0
 
tracymrAuthor Commented:
Ozo,

We are close!

Anyway we can limit to 2 decimal places?  when I test your last one I can still enter 49.999 and it validates to true.
0
 
ozoCommented:
^\$?(?=\d{1,3}(,?\d{3})*(\.\d\d?)?$)([5-9]\d|[1-9][\d,]{2})
0
 
tracymrAuthor Commented:
Ozo,

Perfect!  That last submittal does the trick.

Thanks!
0
 
tracymrAuthor Commented:
Thank you for your lightening fast responses! :-)
0
 
binoboseCommented:
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now