【发布时间】:2019-03-19 22:27:59
【问题描述】:
我正在从包含此字符“|”的 API 检索字符串。我想用“|”分割字符串我尝试了几个选项,但都失败了。
String response="The general String | Yesterday";
String splitResponse = response.split("|");
// also tried this
reponse.split("(?<=|)"); //no success
【问题讨论】:
-
试试
split("\\|") -
split()将返回String[]而不是String对象。