Remove HTML tags from a String

后端 未结 30 3204
误落风尘
误落风尘 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 08:04

    My 5 cents:

    String[] temp = yourString.split("&");
    String tmp = "";
    if (temp.length > 1) {
    
        for (int i = 0; i < temp.length; i++) {
            tmp += temp[i] + "&";
        }
        yourString = tmp.substring(0, tmp.length() - 1);
    }
    

提交回复
热议问题