Java HTML Filter filterHtml(String input)

Here you can find the source of filterHtml(String input)

Description

* Remove HTML from input string.

License

Open Source License

Parameter

Parameter Description
input a parameter

Declaration

public static String filterHtml(String input) 

Method Source Code

//package com.java2s;
/** This code is copyright Articulate Software (c) 2003.  Some
 portions copyright Teknowledge (c) 2003 and reused under the terms of
 the GNU license.  This software is released under the GNU Public
 License <http://www.gnu.org/copyleft/gpl.html>.  Users of this code
 also consent, by use of this code, to credit Articulate Software and
 Teknowledge in any writings, briefings, publications, presentations,
 or other representations of any software which incorporates, builds
 on, or uses this code.  Please cite the following article in any
 publication with references:/*w  ww  .j  a  va2 s  .  c  o  m*/

 Pease, A., (2003). The Sigma Ontology Development Environment, in
 Working Notes of the IJCAI-2003 Workshop on Ontology and Distributed
 Systems, August 9, Acapulco, Mexico.
 See also http://sigmakee.sourceforge.net
 */

public class Main {
    /** ***************************************************************
     * Remove HTML from input string.
     * @param input
     * @return
     */
    public static String filterHtml(String input) {
        // Note use of non-greedy matching.
        String out = input.replaceAll("<.*?>", "");

        // Clean up.
        out = out.replaceAll(" +", " ");
        // Insert a space anywhere a comma isn't followed by a space.
        out = out.replaceAll(",(\\S)", ", $1");

        return out;
    }
}

Related

  1. filterHtml(String body)
  2. filterHTML(String input)
  3. filterHTML(String input)
  4. filterHTML(String s)
  5. filterHtml(String s)
  6. filterHtmlAndTruncate(String s)
  7. filterHtmlAndTruncate(String s)