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
Solved

RegEx in C# to accept decimal

Posted on 2009-07-12
6
696 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to parse the string and split the sub directory names in asp.net 7 54
parse a file and get data out 11 72
JSON  parse help 7 40
Help with error in Query 2 31
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…

790 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