Solved

RegEx in C# to accept decimal

Posted on 2009-07-12
6
688 Views
Last Modified: 2013-12-17
Hi

I need a Regular Expression that accept decimal as:

1 - At maximum 6 digits.
2.- A dot if there is a fraction.
2 - At maximum 2 digit for fraction.

The number must be equal 0.01 or over.


0
Comment
Question by:Almatrodi
  • 3
  • 2
6 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 24837704
I would use the following:

^\d{0,6}(\.\d{1,2})?$
0
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 500 total points
ID: 24837712
this one will avoid a value of zero:
(?!^0*$)(?!^0*\.0*$)^\d{1,6}(\.\d{1,2})?$
0
 
LVL 1

Author Comment

by:Almatrodi
ID: 24837751

Dear Jaime

It is ok for me. But it accepts 0.00
The number must be over 0.01

Waiting

Thanks

0
DevOps Toolchain Recommendations

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

 
LVL 27

Expert Comment

by:ddrudik
ID: 24840446
Consider:
^(?!0+(?:\.00?)?$)\d{0,6}(?:\.\d\d?)?$

Open in new window

0
 
LVL 1

Author Comment

by:Almatrodi
ID: 25156489
It seems that there is no more answer :(

0
 
LVL 1

Author Closing Comment

by:Almatrodi
ID: 31602723
I still did not get the complete answer
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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

914 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