Solved

RegEx in C# to accept decimal

Posted on 2009-07-12
6
704 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:Abdurahman Almatrodi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Abdurahman 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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:Abdurahman Almatrodi
ID: 25156489
It seems that there is no more answer :(

0
 
LVL 1

Author Closing Comment

by:Abdurahman Almatrodi
ID: 31602723
I still did not get the complete answer
0

Featured Post

Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

Question has a verified solution.

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

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…

717 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