[英]Python/regex: Elegant way to check if a string contains ONLY numbers and periods
For example, '5243412..32.432242' would yield true, while '2132100345abcdefgh--#$#' would be false.例如,'5243412..32.432242' 会产生 true,而 '2132100345abcdefgh--#$#' 会产生 false。
This regex这个正则表达式
^[0-9\.]*$
Matches a line only consisting of digits and periods.匹配仅由数字和句点组成的行。
A shortcut is to use '\d' which checks for digits.一个快捷方式是使用 '\d' 检查数字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.