我想寫一個正則表達式,會發現除'.'
以外的所有內容 - 也就是說,只包含'.'
的字符串應返回false
和其他所有內容true
。Java正則表達式來查找除''之外的所有內容。
String regex = "(?!(^\\.$)).*";
String test = ".";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(test);
System.out.println(matcher.find());
有什麼問題合併? –
我沒有看到你的代碼有什麼問題。你能明確指出問題是什麼嗎? – Unihedron
我認爲這會完成這項工作[^ \\。$]。* –