Search code examples
androidhtmlparsingfromhtml

ANDROID--How to take one part of html tag with fromHtml?


I want to take one part of description from html tag. But I do not know how can I apply it?

Here is my Html tag:

İstanbul Çağlayan Adliyesi’nde teröristler tarafından silahla vurularak öldürülen savcı Mehmet Selim Kiraz’ın babası hastanede taziyeleri kabul ederken, yakınları da gözyaşı döktü. Savcı Kiraz’ın cenazesi Adli Tıp Kurumu morguna götürüldü.

I need to parse this part from description.

The following code give me all sentences in the description but I don't want some sentences which are in <a href=...></a> tags:

viewHolder.txtViewDescription.setText(Html.fromHtml(itemsData.get(position).getDescription()));

How can I apply it? Thanks for help...


Solution

  • You can use this Regular expression to remove all anchor tags.

    String your_string = "<a>your html content</a>useful text"
    String exp = "<a href=.*</a>";
    String result = your_string.replaceAll(exp, "");