Remove HTML tags from a String

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

    This should work -

    use this

      text.replaceAll('<.*?>' , " ") -> This will replace all the html tags with a space.
    

    and this

      text.replaceAll('&.*?;' , "")-> this will replace all the tags which starts with "&" and ends with ";" like  , &, > etc.
    

提交回复
热议问题