我試圖防止重複點字符'。'並且僅允許數字/字母如何防止使用Java正則表達式重複字符
例如
"blah...blah".matches(rex)) //false
"..blablah".matches(rex)) //false
"blablah..".matches(rex)) //false
"blab.lah".matches(rex)) //true
"bla.blah".matches(rex)) //true
我試着使用: ^(?!\.\.)([a-zA-Z0-9._\-]*)$
但它僅適用於第二個例子,我怎樣才能使它發揮作用?
你必須使用正則表達式嗎? (可能有一個更簡單的選項) – ItamarG3
你工作過嗎? – ItamarG3
是的,我更喜歡正則表達式 – Canttouchit