Remove HTML tags from a String

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

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

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


        
30条回答
  •  闹比i
    闹比i (楼主)
    2020-11-21 07:41

    I know this is old, but I was just working on a project that required me to filter HTML and this worked fine:

    noHTMLString.replaceAll("\\&.*?\\;", "");
    

    instead of this:

    html = html.replaceAll(" ","");
    html = html.replaceAll("&"."");
    

提交回复
热议问题