0
我有一個像提取文本
some text <p>any text</p>
串從中我需要刪除部分
<p>any text</p>
,結果,得到字符串
some text
我發現教程中的一些示例代碼使用字符串,但我不會rstand如何工作。我是編碼方面的新手,很難,因爲我不懂英文。
private String description;
public void setDescription(String description) {
this.description = description;
if (description.contains("<p>")) {
String musor = description.substring(description.indexOf("<p>"));
String cleanUp = musor.substring(0, musor.indexOf("</p>")+1);
musor = musor.substring(musor.indexOf("<p>"));
this.description = this.description.replace(cleanUp, "");
}
}
也許它的幫助太android.text.Html.fromHtml(description).toString(); – poucleau