我在使用String.replaceAll(String, String)
時,我發現用$
符號替換字符串是行不通的。示例$REPLACEME$
在Linux系統中不會被替換。任何人都知道這是爲什麼?Java替換全部
一些代碼:
String foo = "Some string with $REPLACEME$";
foo = foo.replaceAll("$REPLACEME$", "characters");
System.out.println(foo);
輸出:
Some string with $REPLACEME$
你爲什麼使用'replaceAll'而不是'replace'?你需要*正則表達式嗎? – 2014-10-08 20:30:03