String.replaceAll single backslashes with double backslashes

后端 未结 5 655
孤街浪徒
孤街浪徒 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:00

    Yes... by the time the regex compiler sees the pattern you've given it, it sees only a single backslash (since Java's lexer has turned the double backwhack into a single one). You need to replace "\\\\" with "\\\\", believe it or not! Java really needs a good raw string syntax.

提交回复
热议问题