Link to home
Start Free TrialLog in
Avatar of Lance_Frisbee
Lance_FrisbeeFlag for United States of America

asked on

RegExp Money Validator

I have been messing around with it, but I can't seem to come up with a working validator. This shouldn't be too hard. I just need it to validate an entry of money in millions. (MUST be in millions.)

The format is this:  124.5 M or 124.5M

It needs to allow up to 3 digits, then REQUIRES a decimal and REQUIRES one digit after the decimal, and then a space is OPTIONAL (needs to accept both ways). All of this is followed by a REQUIRED 'M'

If someone could help me out with this, i'd really appreciate it. It's a nagging task...

Lance
ASKER CERTIFIED SOLUTION
Avatar of mmarinov
mmarinov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lance_Frisbee

ASKER

Thank you very much.

Lance
Hmm - I just tested it again, and found that that RegExp doesn't accept 2 and 1 digits which it should.

EXP:

234.0M Passes
23.4M fails
2.3M fails

100.0M passes
10.0M fails
1.0M Fails

ETC...

Suggestions?
Avatar of mmarinov
mmarinov

sorry i've missed "up to"
the expression is
\d{1,3}.\d\s{0,1}M

B..M
Ahh - thanks - I ended up trying \d{1,2,3}.... i was close :P   Thanks!