I see this in GlassFish source code frequently:
string = string.replaceAll("\\\\", "/");
Whoa! FOUR backslashes?!? Yes. That's a regular expression. What we see is FOUR but inside the string itself are TWO literal actual backslashes. The backslashes have to be doubled so that the RegEx parser knows that we are looking for a literal backslash.
What the author of this code really wants to do is something like this:
c:\a\b\c\d ==> c:/a/b/c/d
This can easily be done without the more confusing regex notation and (I assume) the slower regex code like so:
string = string.replace('\\', '/');