Java 字符串替换不起作用
String delimiter = "\\*\\*";
String html = "<html><head></head><body>**USERNAME** AND **PASSWORD**</body></html>";
Map<String, String> mp = new HashMap<String, String>();
mp.put("USERNAME", "User A");
mp.put("PASSWORD", "B");
for (Entry<String, String> entry : mp.entrySet()) {
html.replace(delimiter + entry.getKey()+ delimiter, entry.getValue());
}
这通常应该替换这两个字符串,但事实并非如此。有人有想法吗?