Regular Expression for Matching Numbers with Optional Decimal Points
This regular expression matches a string that contains one or two digits ('\d{1,2}') followed by an optional decimal point and one or two more digits ('(.\d{1,2})?').
Here are some examples of strings that would match this regular expression:
- '1'
- '12'
- '1.5'
- '22.75'
And here are some examples of strings that would not match:
- '0.123' (more than two digits after the decimal point)
- '3.' (decimal point without any digits after it)
- '1.23456' (more than two digits after the decimal point)
原文地址: https://www.cveoy.top/t/topic/lGqc 著作权归作者所有。请勿转载和采集!