I am in need to replace
\\\\\\s+\\\\$\\\\$ to $$
I used
String s = \" $$\"; s = s.replaceAll(\"\\\\s+\\\\$\\\\$\",\"$$\"
This is the right way. Replace the literar $ by escaped \\$ str.replaceAll("\\$", "\\\\\\$")
str.replaceAll("\\$", "\\\\\\$")