Solved

RegExp Money Validator

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

12 Experts available now in Live!

Get 1:1 Help Now