str = "D:\code\erp\target\class\artifacts\erp_war_exploded\/attachment/image/seal/4//5858.png"
我想把str的\/和//都替換成/
String REGEX = "\/|//";
Pattern p = Pattern.compile(REGEX);
Matcher m = p.matcher(str);
str=m.replaceAll("/");
這樣寫為什麼不行??該怎麼搞?
String str ="D:\\code\\erp\\target\\class\\artifacts\\erp_war_exploded\\/attachment/image/seal/4//5858.png";
System.out.println(str);
// 我想把str的\/和//都替換成/
String REGEX = "\\\\/|//";
Pattern p = Pattern.compile(REGEX);
Matcher m = p.matcher(str);
str=m.replaceAll("/");
System.out.println(str);
運行結果:
D:\code\erp\target\class\artifacts\erp_war_exploded\/attachment/image/seal/4//5858.png
D:\code\erp\target\class\artifacts\erp_war_exploded/attachment/image/seal/4/5858.png