This is the question "what the hell is here." I really don't need a solution.
I had to replace all single backslashes in String with double backslashes. This is what I ended up doing ...
strRootDirectory = strRootDirectory.replaceAll("\\\\", "\\\\\\\\");
... where strRootDirectory is java.lang.String above.
Now I understand four backslashes for the first argument: the regular expression expects two backslashes to indicate a single backslash, and java wants them to double. It's fine.
BUT, what the hell happens with eight backslashes for the second argument? Shouldn't a replacement string be a literal (non-regular, I mean) string? I expected that in the second argument, four backslashes would be required to represent two backslashes.
source
share