Need Regex Money No $

Charles Baldo
Charles Baldo used Ask the Experts™
on
Please I need a reg ex that will do Money without the $

numbers only
commas in right place
2 dp
no $
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
Commented:
Hi,

pls try
(([0-9]{1,3}),?.?\d{0,2})(([0-9]{1,3})?,?.?\d{0,2})?(\.\d{0,2})?

Open in new window

REgards
Dustin SaundersCo-Founder and Chief Architect
Top Expert 2016

Commented:
If it has a $ on it, then it's a string right?  Why not just use:

string.replace("$",string.Empty)

Open in new window


or
string.Substring(1)

Open in new window

kaufmedGlanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015

Commented:
^\d{1,3}(,\d{3})*(\.\d\d)?$

Open in new window


If you don't want the decimal part to be optional, then remove the ?
Charles BaldoSoftware Developer

Author

Commented:
Worked best
kaufmedGlanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015

Commented:
I fail to see how considering it allows things like:

1,000,0.00

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial