String.replaceAll single backslashes with double backslashes

后端 未结 5 607
孤街浪徒
孤街浪徒 2020-11-22 15:01

I\'m trying to convert the String \\something\\ into the String \\\\something\\\\ using replaceAll, but I k

5条回答
  •  逝去的感伤
    2020-11-22 16:03

    To avoid this sort of trouble, you can use replace (which takes a plain string) instead of replaceAll (which takes a regular expression). You will still need to escape backslashes, but not in the wild ways required with regular expressions.

提交回复
热议问题