I'm attempting to build a regular expression (.NET) to match a percentage with 4 decimal places. The 4 decimal places are required. The range looks like:
0.0001 to 100.0000
So far, I've come up with:
(?:[^0]+[1-100]{1,3})\.(?:\d{4})
However, I'm a bit unsure on how to add a few other requirements to this expression. I need:
- No leading zeroes before the decimal point. 42.4214 is allowed, 042.4214 is not. 1.0000 is allowed but 001.0000 is not. Etc..
- Up to 3 characters allowed before decimal without leading zeroes.
- If the number before the decimal is 100, do not allow the number after the decimal to be anything other than 0000, so 100.0000 is allowed, but 100.0135 is not allowed. (Is this even possible with a regex?)
Help is appreciated!