Try the following:
^[0-9]*(\.[0-9]{1,2})?$
According to your second example, but allows one or two decimal places, and makes the full decimal part optional.
[EDIT]
The OP changed the question criteria - see comments below. Now he wants the digits to the decimal point to allow up to six digits and asked me to edit the answer.
All that is needed is to replace * (for any number of digits) with {0,6} (between zero and six digits). If you need at least one digit, then it will be {1,6} .
Here is a modified regex:
^[0-9]{0,6}(\.[0-9]{1,2})?$
Spudley
source share