Remove HTML tags from a String

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

    I know it is been a while since this question as been asked, but I found another solution, this is what worked for me:

    Pattern REMOVE_TAGS = Pattern.compile("<.+?>");
        Source source= new Source(htmlAsString);
     Matcher m = REMOVE_TAGS.matcher(sourceStep.getTextExtractor().toString());
                            String clearedHtml= m.replaceAll("");
    

提交回复
热议问题