?
Solved

RegEx in C# to accept decimal

Posted on 2009-07-12
6
Medium Priority
?
708 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 1500 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 1500 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
Suggested Courses

765 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