String replace a Backslash

前端 未结 8 926
死守一世寂寞
死守一世寂寞 2020-11-27 06:50

How can I do a string replace of a back slash.

Input Source String:

sSource = \"http://www.example.com\\/value\";

8条回答
  •  误落风尘
    2020-11-27 07:09

    s.replaceAll ("\\\\", "");
    

    You need to mask a backslash in your source, and for regex, you need to mask it again, so for every backslash you need two, which ends in 4.

    But

    s = "http://www.example.com\\/value";
    

    needs two backslashes in source as well.

提交回复
热议问题