Solved

RegExp Money Validator

Posted on 2004-04-29
5
375 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now