我试图防止重复点字符'。'并且仅允许数字/字母如何防止使用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