Its doesn't like it because
is the escape character in C like languages (even as an escape on this forum) Which makes it a poor choice for a file seperator but its a change they introduced in MS-DOS...
The problem you have is that you have escape the
twice so \hostpath
becomes \\host\path
in the string but for the regex has to be escaped again :P \\\\host\\path
If you can use a forward slash this is much simpler
String jarPath = "//xyz/abc/wtf/lame/";
jarPath = jarPath.replaceAll("//xyz/abc", "z:");
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…