Solved

RegExp Money Validator

Posted on 2004-04-29
5
376 Views
Last Modified: 2012-05-04
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
0
Comment
Question by:Lance_Frisbee
  • 3
  • 2
5 Comments
 
LVL 28

Accepted Solution

by:
mmarinov earned 25 total points
ID: 10953106
the regular expression is

\d\d\d.\d\s{0,1}M

B..M
0
 
LVL 2

Author Comment

by:Lance_Frisbee
ID: 10953424
Thank you very much.

Lance
0
 
LVL 2

Author Comment

by:Lance_Frisbee
ID: 10953488
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?
0
 
LVL 28

Expert Comment

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

B..M
0
 
LVL 2

Author Comment

by:Lance_Frisbee
ID: 10953589
Ahh - thanks - I ended up trying \d{1,2,3}.... i was close :P   Thanks!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
More on Time zones in vb 2010 12 38
Store results in vb.net 3 20
Database Connections Not being returned to Connection Pool 7 25
Sending receiving text messages in vb.net 15 33
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question