public class StringReplace {
public static void main(String[] args) {
String in = "thisLocation + escape(\"####\") ";
String out = in.replaceAll("####", "C:\\Documents and Settings\\ap\\My Documents\\w r_file");
System.out.println(out);
}
}
Here is the output when you run under (for me): Java 1.6.0_03
thisLocation + escape("C:Documents and SettingsapMy Documentsw r_file")
Why are the backslashes swallowed up? Under java.util.regex.Pattern javadocs, '\\' is listed as backslash.
This used to work in Java 1.5.11.