Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

RegExp Money Validator

Posted on 2004-04-29
5
Medium Priority
?
382 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 100 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

886 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