I am in need to replace
\\\\\\s+\\\\$\\\\$ to $$
I used
String s = \" $$\"; s = s.replaceAll(\"\\\\s+\\\\$\\\\$\",\"$$\"
$ has special meaning in the replacement string as well as in the regex, so you have to escape it there, too:
$
s=s.replaceAll("\\s+\\$\\$", "\\$\\$");