On a Flutter TextField
I have the following FilteringTextInputFormatter
:
FilteringTextInputFormatter.allow(RegExp(r"^\d+\.?\d{1,2}"));
It tries to match a decimal number up to two places, but I can't input any numbers into the TextField
.
After messing with RegExr, I found that what I wanted was:
RegExp(r"^\d{1,4}(\.\d{0,2})?")
This expression allows four digits with two decimal places.