[c#] Regular expression for decimal number

I need to validate a textbox input and can only allow decimal inputs like: X,XXX (only one digit before decimal sign and a precision of 3).

I'm using C# and try this ^[0-9]+(\.[0-9]{1,2})?$?

This question is related to c# regex decimal

The answer is


^[0-9]([.,][0-9]{1,3})?$

It allows:

0
1
1.2
1.02
1.003
1.030
1,2
1,23
1,234

BUT NOT:

.1
,1
12.1
12,1
1.
1,
1.2345
1,2345

Similar questions with c# tag:

Similar questions with regex tag:

Similar questions with decimal tag: