Como mostrado abaixo:
pacote com.lyt.base.util; importar java.util.regex.pattern; public class filterhtmlutil {public static string html2text (string inputString) {string htmlstr = inputString; // string string com tag html string 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; tente {string regex_script = "<[// s]*? script [^>]*?> [// s/s]*? <[// s]*? // [//]*? script [// s]*?>"; // define a expressão regular do script {ou <script [^>]*?> [// s/s]*? // define a expressão regular {ou <style [^>]*?> [// s/s]*? </// style>} string regex_html = "<[^>]+>"; // Defina a expressão regular p_script = Pattern.compile (regex_script, padrony.case_insensitive); m_script = p_script.matcher (htmlstr); htmlstr = m_script.replaceall (""); // Filtrar tag de script p_style = padrony.compile (regex_style, padrony.case_insensitive); m_style = p_style.matcher (htmlstr); htmlstr = m_style.replaceall (""); // Tag de estilo de filtro p_html = padrony.compile (regex_html, padrony.case_insensitive); m_html = p_html.matcher (htmlstr); htmlstr = m_html.replaceall (""); // filtrar tag html textstr = htmlstr; } catch (Exceção e) {e.printStackTrace (); } return textstr; // retorna text string}}O exemplo acima das tags HTML de filtragem Java para obter informações de texto simples é todo o conteúdo que compartilho com você. Espero que você possa lhe dar uma referência e espero que você possa apoiar mais o wulin.com.