java 去掉html标签
来源:互联网 发布:网络暴力的调查报告 编辑:程序博客网 时间:2024/05/21 10:07
java 去掉html标签
import java.util.regex.Matcher; import java.util.regex.Pattern; public class HTMLSpirit{ public static String delHTMLTag(String htmlStr){ String regEx_script="<script[^>]*?>[\\s\\S]*?<\\/script>"; //定义script的正则表达式 String regEx_style="<style[^>]*?>[\\s\\S]*?<\\/style>"; //定义style的正则表达式 String regEx_html="<[^>]+>"; //定义HTML标签的正则表达式 Pattern p_script=Pattern.compile(regEx_script,Pattern.CASE_INSENSITIVE); Matcher m_script=p_script.matcher(htmlStr); htmlStr=m_script.replaceAll(""); //过滤script标签 Pattern p_style=Pattern.compile(regEx_style,Pattern.CASE_INSENSITIVE); Matcher m_style=p_style.matcher(htmlStr); htmlStr=m_style.replaceAll(""); //过滤style标签 Pattern p_html=Pattern.compile(regEx_html,Pattern.CASE_INSENSITIVE); Matcher m_html=p_html.matcher(htmlStr); htmlStr=m_html.replaceAll(""); //过滤html标签 return htmlStr.trim(); //返回文本字符串 } }
阅读全文
0 0
- java去掉html标签
- java去掉html标签
- java 去掉html标签
- java 去掉html标签
- java去掉html标签 必须首先去掉 "
- java中去掉html标签
- java 去掉html标签 使用正则表达式删除HTML标签。
- JAVA去掉字符串里的html标签。
- java正则表达式去掉所有HTML标签
- java正则表达式去掉所有HTML标签
- java正则表达式去掉所有HTML标签
- java正则表达式去掉所有HTML标签
- java正则去掉所有html标签
- java正则表达式去掉html标签
- 去掉HTML的标签
- js去掉HTML标签
- 去掉HTML标签
- 去掉HTML标签
- 首页实现_主菜单实现
- wan2003服务器 数据库链接错误的解决
- 精神导师能带给我们什么?
- 关于配置Maven项目jdk
- Java基础总结-基本语法概念-3
- java 去掉html标签
- 【个人笔记】json基本操作
- php从数据库中取二进制流文件转换为图片,图片以二进制流存入数据库实现
- 一生学做人
- 【python】mysql connector
- 二叉树的建立和遍历程序代码(Java,C)
- 学习Java分为几个阶段,分别是什么?
- Intellij – 无法使用较新的Java 8类 – 错误:“API的用法记录为@since 1.6+
- nginx