我从 json 得到一个字符串
"author":"ricobeemer<\/span>"
.
当我检索字符串时
String author = c.getString("author");
“作者”字符串告诉我
<span class="reviewer"itmprop="name">ricobeemer</span>
因为我只想将“ricobeemer”存储在作者字符串中。谁能帮我怎么做?提前致谢。
简单而最好
Html.fromHtml(author).toString();
试试这个,它对我有用:
Html.fromHtml(author).toString();
这是完成它的一种快速而肮脏的方法:
String author = c.getString("author")
.substring(c.getString("author")
.lastIndexOf("\">"), c.getString("author").lastIndexOf("</"));
您可以应用一些正则表达式匹配来从和之间提取,>
如下<
所示:
String author = c.getString("author");
Pattern p = Pattern.compile("(?<=>)(.*)(?=<)");
Matcher m = p.matcher(author);
if (m.find()) {
author = m.group();
}