Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reg Exp Help: Validate Currency

Status
Not open for further replies.

jfrost10

Programmer
Jun 3, 2001
2,004
CA
Hey guys,

I have need to write a reg exp that will look at a number formatted for currency (i.e. 200,000,000.00), and not yak as long as the only non-numeric items are the , and the .

Here's what I'm using so far, and it works...kinda:
^\d*,*\d*\.?\d*

Problem I'm having is that this will only work if the value is less than 999,999.99. Is there a way for me to cover any length of number for commas instead of writing a reg exp that looks like this:
^\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*\.?\d*
???

Thanks,

jack
 
How about this:
Code:
^(\d{,3},)*\d{,3}\.\d{,2}
This would match 3 numbers and a comma, any number of times, followed by up to 3 numbers, the dot, and then a maximum of 2 numbers. //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top