Java Regex String Replace HTML replaceHtml(String html)

Here you can find the source of replaceHtml(String html)

Description

replace Html

License

Apache License

Declaration

public static String replaceHtml(String html) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

    public static String replaceHtml(String html) {
        if (isBlank(html)) {
            return "";
        }/*from  w  w w  .  jav  a2  s  .c  o m*/
        String regEx = "<.+?>";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(html);
        String s = m.replaceAll("");
        return s;
    }

    public static boolean isBlank(String str) {
        return (isEmpty(str) || (str.trim().length() == 0));
    }

    public static boolean isEmpty(String str) {
        return (str == null || str.length() == 0);
    }
}

Related

  1. removeTag(String tagname, String xmlstring)
  2. removeTag(String text)
  3. removeTags(String html)
  4. removeTags(String input, List knownTagList)
  5. removeTags(String string)
  6. replaceHtml(String html)
  7. replaceHtmlEntities(final String text)
  8. replaceHtmlEntities(String aText, boolean preserveFormatting)
  9. replaceTags(String payload, Map tags)