0
所以這裏是我的問題。我有串像評論中的Java:從屬性文件中正則表達式的錯誤
String s = "// the "then" clause: decrease"
,當我這樣做:
System.out.println(s.matches("(^(//).+)"));
其true
。 但是,當我有屬性文件,其中
listing = "(^(//).+)"
,做同樣的
System.out.println(s.matches(resourceBundle.getString("listing")));
我收到false
。爲什麼?什麼正則表達式必須在屬性中才能得到真實?謝謝
如果你打印出'resourceBundle.getString(「listing」)',它說什麼? –
這裏是sout:'「(^(//)。+)」'同樣的正則表達式 –
這可能是因爲你必須轉義//,你可以把它放在屬性文件'listing =「(^(\ /\//.++)「'看看這是什麼? –