String replace a Backslash

前端 未结 8 900
死守一世寂寞
死守一世寂寞 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条回答
  •  Happy的楠姐
    2020-11-27 07:07

    sSource = sSource.replace("\\/", "/");
    
    • String is immutable - each method you invoke on it does not change its state. It returns a new instance holding the new state instead. So you have to assign the new value to a variable (it can be the same variable)
    • replaceAll(..) uses regex. You don't need that.

提交回复
热议问题