【发布时间】:2012-03-10 15:24:31
【问题描述】:
我有一个带有 html 标签的字符串。我想完全删除 html 标签。我怎样才能做到这一点? 字符串是这样的
<messageContent><p><a href="http://www.business-standard.com/india/news/markets-trade-flatpositive-bias/159747/on" target="_blank"><strong>Markets trade flat with positive bias</strong></a><br />
<a href="http://www.moneycontrol.com/news/local-markets/nifty-choppy-icici-bank-infosys-wipro-gain_677519.html" target="_blank"><strong>Nifty choppy; ICICI Bank, Infosys, Wipro gain</strong></a><br />
BSE 17127.09 (-46.20)<br />
NSE 5208.15 (-14.25)</p>
</messageContent>
【问题讨论】:
-
第 1 步:研究这个问题是否已经得到解答。 ;)
-
尚无太多研究
-
您应该在此处提问之前这样做,并将结果包含在您的问题中,以防您无法自行解决。我现在投票结束这个问题,因为我在一分钟内找到了答案,我想你也会打到它。 :)
-
Pattern tags = Pattern.compile ("</?[^>]+>"); Matcher match = tags.matcher (yourContent); // here you specify the string you want to modify (HTML) String result = match.replaceAll(""); -
@Dinesh:他什么都没做,你仍然可以编辑你的问题。