Remove HTML tags from a String

后端 未结 30 3233
误落风尘
误落风尘 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:40

    The accepted answer of doing simply Jsoup.parse(html).text() has 2 potential issues (with JSoup 1.7.3):

    • It removes line breaks from the text
    • It converts text <script> into
提交回复
热议问题