Remove HTML tags from a String in Java

Use a HTML parser instead of regex. This is dead simple with Jsoup.
public static String html2text(String html) {
    return Jsoup.parse(html).text();
Jsoup also supports removing HTML tags against a customizable whitelist, which is very useful if you want to allow only e.g. <b><i> and <u>.

Post a Comment

Featured Post

Updated Coupons / promo codes for Google Apps for Work / Business

To redeem: 1. Sign up for Google Apps   2. Go to your billing settings  3. Choose your payment plan  4. Enter your promo code ...