Products
GG网络技术分享 2025-03-18 16:15 1
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
Demand feedback