/^\\d{1,2}(\.\d{1,2})?$/
This regular expression matches a string that starts with one or two digits, followed by an optional decimal point and one or two more digits after the decimal point.
Example matches:
- 4
- 12.5
- 99.99
Example non-matches:
- 0.5 (must have at least one digit before the decimal point)
- 3.456 (only allows up to two digits after the decimal point)
- 12345 (too many digits before the decimal point)
原文地址: https://www.cveoy.top/t/topic/twP 著作权归作者所有。请勿转载和采集!