Como se muestra a continuación:
paquete com.lyt.base.util; import java.util.regex.pattern; public class FilterHtmlutil {public static String html2Text (string inputString) {String htmlStr = inputString; // cadena de cadena con la etiqueta html cadena textstr = ""; java.util.regex.pattern p_script; java.util.regex.matcher m_script; java.util.regex.pattern p_style; java.util.regex.pattern p_html; java.util.regex.matcher m_html; Pruebe {String regex_script = "<[// s]*? // Definir la expresión regular del script {o <script [^>]*?> [// s // s]*? <///1 script>} string regex_style = "<[// s]*? Style [^>]*?> [// s // s]*? <// s]*? // [// S]*?>"; // Defina la expresión regular {o <style [^>]*?> [// s // s]*? </// style>} string regex_html = "<[^>]+>"; // Definir la expresión regular p_script = patrón.compile (regex_script, patrón.case_insensitive); m_script = p_script.matcher (htmlstr); htmlstr = m_script.replaceall (""); // Filtro de la etiqueta de script p_style = patrón.compile (regex_style, patrón.case_insensitive); m_style = p_style.matcher (htmlstr); htmlstr = m_style.replaceall (""); // Etiqueta de estilo de filtro p_html = patrón.compile (regex_html, patrón.case_insensitive); m_html = p_html.matcher (htmlstr); htmlstr = m_html.replaceall (""); // Filtrar la etiqueta html textstr = htmlstr; } catch (Exception e) {E.PrintStackTrace (); } return textstr; // return text String}}El ejemplo anterior de las etiquetas HTML de filtración de Java para obtener información de texto plano es todo el contenido que comparto con usted. Espero que pueda darle una referencia y espero que pueda apoyar más a Wulin.com.