Eight backslashes required to replace single backslash with double backslashes?

后端 未结 6 464
借酒劲吻你
借酒劲吻你 2021-01-18 09:37

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

6条回答
  •  不思量自难忘°
    2021-01-18 10:12

    "\\\\\\\\" leads to an in memory representation of a string with 4 backslashes: \\\\. Although the second string isn't a regex string, backslashes and dollar signs are still special characters in it, so they need to be escaped.

提交回复
热议问题