I want to build a regular expression for float number with maximum Length 5. My number can have separator ',' or '.' or it can be a natural number (not float)
I Want to allow any of this values
XXXXX
XXXX.X
XXX.XX
XX.XXX
X.XXXX
X.X
X.XX
X.XXX
X.XXXX
XX.X
XXX.X
etc.
Simple method:
^\d{1,5}$|^(?=\d+[.,]\d+$).{3,6}$

Debuggex Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With