Java: replaceAll doesn't work well with backslash?

前端 未结 9 1527
北荒
北荒 2021-01-25 12:56

I\'m trying to replace the beginning of a string with backslashes to something else. For some weird reason the replaceAll function doesn\'t like backslashes.

Str         


        
9条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-25 13:55

    You can use replace() method also which will remove \\\\xyz\\abc from the String

    String jarPath = "\\\\xyz\\abc\\wtf\\lame\\";
    jarPath = jarPath.replace("\\\\xyz\\abc", "z:");
    

提交回复
热议问题