Java Regex String Replace HTML removeTags(String html)

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

Description

remove Tags

License

Open Source License

Declaration

public static final String removeTags(String html) 

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 Pattern _patternTag = Pattern.compile("\\s*<[^>]*?>\\s*");

    public static final String removeTags(String html) {

        // replace all tags with spaces
        Matcher m = _patternTag.matcher(html);
        String text = m.replaceAll(" ");

        return text;
    }/*  w  w w . j  av a  2 s . c om*/
}

Related

  1. removeAllTags(String html)
  2. removeAllTags(String htmlText)
  3. removeAllTags(String input)
  4. removeTag(String tagname, String xmlstring)
  5. removeTag(String text)
  6. removeTags(String input, List knownTagList)
  7. removeTags(String string)
  8. replaceHtml(String html)
  9. replaceHtml(String html)