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

Python 正则表达式验证带分隔符的数字

2014-09-09 16:04 281 查看
1. Find any decimal or octal integer with optional underscores in a larger body of text
\b[0-9]+(_+[0-9]+)*\b

2. Find any hexadecimal integer with optional underscores in a larger body of text
\b0[xX][0-9a-fA-F]+(_+[0-9a-fA-F]+)*\b

3. Find any binary integer with optional underscores in a larger body of text
\b0[bB][01]+(_+[01]+)*\b

4. Find any decimal, octal, hexadecimal, or binary integer with optional underscores in a larger body of text
\b([0-9]+(_+[0-9]+)*|0[xX][0-9a-fA-F]+(_+[0-9a-fA-F]+)*|0[bB][01]+(_+[01]+)*)\b
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: