簡體   English   中英

Python/regex:檢查字符串是否僅包含數字和句點的優雅方法

[英]Python/regex: Elegant way to check if a string contains ONLY numbers and periods

例如,'5243412..32.432242' 會產生 true,而 '2132100345abcdefgh--#$#' 會產生 false。

這個正則表達式

^[0-9\.]*$

匹配僅由數字和句點組成的行。

一個快捷方式是使用 '\d' 檢查數字。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM