This is a \"what the heck is going on here\" question. I don\'t actually need a solution.
I had to replace all single backslashes in a String with double backslashe
The second argument isn't a regex-string, but a regex-replacement-string, in which the backslash also has a special meaning (it is used to escape the special character $
used for variable interpolation and is also used to escape itself).
From The API:
Note that backslashes (
\
) and dollar signs ($
) in the replacement string may cause the results to be different than if it were being treated as a literal replacement string; seeMatcher.replaceAll
. UseMatcher.quoteReplacement(java.lang.String)
to suppress the special meaning of these characters, if desired.-- http://download.oracle.com/javase/6/docs/api/java/lang/String.html#replaceAll(...)