How to replace || (two pipes) from a string with | (one) pipe

后端 未结 5 1606
醉话见心
醉话见心 2021-01-15 00:24

I am getting response for some images in json format within this tag:

\"xmlImageIds\":\"57948916||57948917||57948918||57948919||57948920||57948921||57

5条回答
  •  日久生厌
    2021-01-15 00:41

    According to http://docs.oracle.com/javase/6/docs/api/java/lang/String.html, replace() takes chars instead of Strings. Perhaps you should try replaceAll(String, String) instead? Either that, or try changing your String ("") quotation marks into char ('') quotation marks.

    Edit: I just noticed the overload for replace() that takes a CharSequence. I'd still give replaceAll() a try though.

提交回复
热议问题