Removes all html tags from a String via regex and trims the resulting string. - Android java.lang

Android examples for java.lang:String HTML

Description

Removes all html tags from a String via regex and trims the resulting string.

Demo Code



public class Main{
    /**/*from   w  w  w . j ava2 s .c o m*/
     * Removes all html tags from a {@link String} and trims the resulting string.
     * 
     * @param content String that contains html tags
     * @return the String without html tags
     */
    public static String removeHtmlTags(String content) {
        return content.replaceAll("\\<.*?\\>", "").trim();
    }
}

Related Tutorials