Java Regex String Replace HTML removeAllHtmlTag(String str)

Here you can find the source of removeAllHtmlTag(String str)

Description

remove All Html Tag

License

Open Source License

Declaration

public static String removeAllHtmlTag(String str) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    private static final String REGULAR_HTML_TAG = "<([^>]*)>";

    public static String removeAllHtmlTag(String str) {
        Pattern pattern = Pattern.compile(REGULAR_HTML_TAG);
        Matcher matcher = pattern.matcher(str);
        StringBuffer sb = new StringBuffer();
        boolean result1 = matcher.find();
        while (result1) {
            matcher.appendReplacement(sb, "");
            result1 = matcher.find();//  w w w  .  jav a2s .co  m
        }
        matcher.appendTail(sb);
        return sb.toString();
    }
}

Related

  1. removeAllTags(String html)
  2. removeAllTags(String htmlText)
  3. removeAllTags(String input)
  4. removeTag(String tagname, String xmlstring)