我有一张图片路径:"UploadFile\\/UserProfile\\/Female.jpg"
。如何将"\\/"
替换为"/"
?
我试过了:
replaceAll("\\/","/")
replaceAll("\\\\/","/")
代码:
adapter_profilepic = objUser.getProfilePicture().replaceAll("\\/","/");
答案 0 :(得分:1)
String src = "UploadFile\\/UserProfile\\/Female.jpg";
src = src.replaceAll("\\\\/","/");
System.out.println(src);
输出:
UploadFile/UserProfile/Female.jpg
你说你试过了,但又检查了一下。
答案 1 :(得分:0)
根据documentation,您的字符串将用作regular expression
。为什么你不使用replace:
String adapter_profilepic = objUser.getProfilePicture().replace("\\\\/","/");