Remove HTML tags from a String

后端 未结 30 3105
误落风尘
误落风尘 2020-11-21 07:35

Is there a good way to remove HTML from a Java string? A simple regex like

replaceAll("\\\\<.*?>", &quo         


        
30条回答
  •  再見小時候
    2020-11-21 07:44

    One more way can be to use com.google.gdata.util.common.html.HtmlToText class like

    MyWriter.toConsole(HtmlToText.htmlToPlainText(htmlResponse));
    

    This is not bullet proof code though and when I run it on wikipedia entries I am getting style info also. However I believe for small/simple jobs this would be effective.

提交回复
热议问题