Forward slash in Java Regex

后端 未结 3 1621
甜味超标
甜味超标 2020-12-08 18:24

I can\'t figure out why the following code doesn\'t behave as expected

\"Hello/You/There\".replaceAll(\"/\", \"\\\\/\");
  • Expected out
3条回答
  •  北海茫月
    2020-12-08 18:50

    There is actually a reason behind why all these are messed up. A little more digging deeper is done in this thread and might be helpful to understand the reason why "\\" behaves like this.

提交回复
热议问题