1. Mandatory integer and fraction
^[0-9]{1,3}(,[0-9]{3})*\.[0-9]+$
2. Mandatory integer and optional fraction. Decimal dot must be omitted if the fraction is omitted
^[0-9]{1,3}(,[0-9]{3})*(\.[0-9]+)?$
3. Optional integer and optional fraction. Decimal dot must be omitted if the fraction is omitted.
^([0-9]{1,3}(,[0-9]{3})*(\.[0-9]+)?|\.[0-9]+)$
4. The preceding regex, edited to find the number in a larger body of text
\b[0-9]{1,3}(,[0-9]{3])*(\.[0-9]+)?\b|\.[0-9]+\b
Python 正则表达式验证有千位分隔符的数字
最新推荐文章于 2024-06-27 20:45:00 发布