您的位置:首页 > 编程语言 > Python开发

Python 正则表达式验证有千位分隔符的数字

2014-09-12 10:14 447 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: