Here you can find the source of filterHTML(String s)
Parameter | Description |
---|---|
s | the String to filter |
public static String filterHTML(String s)
//package com.java2s; public class Main { /**//from w ww.j a v a2s .c o m * Filters out all HTML tags. * * @param s the String to filter * @return the filtered String */ public static String filterHTML(String s) { if (s == null) { return null; } s = s.replaceAll("<", ""); s = s.replaceAll(">", ""); s = s.replaceAll(" ", ""); s = s.replaceAll("(?s)<[Ss][Cc][Rr][Ii][Pp][Tt].*?>.*?</[Ss][Cc][Rr][Ii][Pp][Tt]>", ""); s = s.replaceAll("(?s)<[Ss][Tt][Yy][Ll][Ee].*?>.*?</[Ss][Tt][Yy][Ll][Ee]>", ""); s = s.replaceAll("(?s)<!--.*?-->", ""); s = s.replaceAll("(?s)<.*?>", ""); return s; } }