Comme indiqué ci-dessous:
package com.lyt.base.util; importer java.util.regex.pattern; public class filterHtmLutil {public static String html2text (string inputString) {string htmlstr = inputString; // String String avec html tag 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; essayez {String regex_script = "<[// s] *? Script [^>] *?> [// S // S] *? <[// S] *? // [// S] *? Script [// S] *?>"; // Définir l'expression régulière du script {ou <script [^>] *?> [// s // s] *? </// script>} chaîne regex_style = "<[// s] *? Style [^>] *?> [// s // s] *? <[// s] *? // [// s] *?>"; // définir l'expression régulière {ou <style [^>] *?> [// s // s] *? </// style>} chaîne regex_html = "<[^>] +>"; // Définissez l'expression régulière p_script = motive.compile (regex_script, pattern.case_insensitive); m_script = p_script.matcher (htmlstr); htmlstr = m_script.replaceAll (""); // Filtre Script TAG P_STYLE = Pattern.Compile (regex_style, pattern.case_insensitive); m_style = p_style.matcher (htmlstr); htmlstr = m_style.replaceAll (""); // Filtre Style Tag p_html = motive.compile (regex_html, pattern.case_insensitive); m_html = p_html.matcher (htmlstr); htmlstr = m_html.replaceAll (""); // filtre html tag textstr = htmlstr; } catch (exception e) {e.printStackTrace (); } return textstr; // return Text String}}L'exemple ci-dessus de Java filtrant les balises HTML pour obtenir des informations en texte brut est tout le contenu que je partage avec vous. J'espère que vous pourrez vous faire référence et j'espère que vous pourrez soutenir Wulin.com plus.