## 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
Solved

# RegEx in C# to accept decimal

Posted on 2009-07-12
696 Views
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
Question by:Almatrodi
• 3
• 2

LVL 55

Accepted Solution

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

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

LVL 55

Assisted Solution

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

ID: 24837751

Dear Jaime

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

Waiting

Thanks

0

LVL 27

Expert Comment

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

LVL 1

Author Comment

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

0

LVL 1

Author Closing Comment

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

## Featured Post

Question has a verified solution.

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