How to remove html tag from string?
public String removeHTMLTag(String html) {
String finalString = "";
try {
finalString = html.replaceAll("\\<.*?>", "");
finalString = finalString.replaceAll("\\&.*?;", "");
finalString = finalString.replace("\r\n", " ");
finalString = finalString.replace("\n", " ");
finalString = finalString.replace("\t", " ");
finalString = finalString.replaceAll("\\<.*?>", "");
finalString = finalString.replaceAll("\\s+", " ");
finalString = finalString.trim();
// System.out.println(finalString);
return finalString;
} catch (Exception e) {
e.printStackTrace();
}
return html;
}
String finalString = "";
try {
finalString = html.replaceAll("\\<.*?>", "");
finalString = finalString.replaceAll("\\&.*?;", "");
finalString = finalString.replace("\r\n", " ");
finalString = finalString.replace("\n", " ");
finalString = finalString.replace("\t", " ");
finalString = finalString.replaceAll("\\<.*?>", "");
finalString = finalString.replaceAll("\\s+", " ");
finalString = finalString.trim();
// System.out.println(finalString);
return finalString;
} catch (Exception e) {
e.printStackTrace();
}
return html;
}
Comments
Post a Comment