-2
我需要一個正則表達式斯卡拉匹配只爲0.0或0.00或0.000。 我怎樣才能做到這一點?Scala的正則表達式零Double值
我曾嘗試下面的斯卡拉正則表達式,但如預期
val reg = "0\\.0{1,}".r
此正則表達式總是對所有的測試用例
測試用例-1返回TRUE它不工作: - 無法
val str = "0."
val matchFound = reg.findFirstMatchIn(str).isEmpty
matchFound: Boolean = true
Testcase-2: - 失敗
val str = "0.89"
val matchFound = reg.findFirstMatchIn(str).isEmpty
matchFound: Boolean = true
測試用例-3: - 無法
val str = "0.abc"
val matchFound = reg.findFirstMatchIn(str).isEmpty
matchFound: Boolean = true