String replace a Backslash

前端 未结 8 855
死守一世寂寞
死守一世寂寞 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
     sSource = StringUtils.replace(sSource, "\\/", "/")
    
    0 讨论(0)
  • 2020-11-27 07:16

    you have to do

    sSource.replaceAll("\\\\/", "/");
    

    because the backshlash should be escaped twice one for string in source one in regular expression

    0 讨论(0)
提交回复
热议问题