html代码中使用正则匹配字符串

飞翔的都江堰人 2018-04-20 05:50:15
前置条件
1.mysql中content字段存储内容是将整个聊天界面html代码存到字段中
2.模糊查询聊天内容 如:想查询聊天记录中是否提到color这个单词
3.结果是以前是通过like 匹配整个content字段的内容 所以把标签里style样式的color也查出来了 导致查询数据不对

目的:通过正则判断 <>这里的内容是否包含要配置的字符串</>

以下是截取的一段html代码

<he tm="1524216179821">
附近的上班</he>
<he tm="1524216187823"></a></he>
<he tm="1524216196823"><a></a></he>
<he tm="152421622082"><input>kjdsfhggo流星</input></he>
<insert tm="1524216260626" oid="1690" na="小明" /><j tm="1524216269463" na="小明"><span style="font-family: Tahoma;mso-ascii-theme-font: minor-fareast;color: rgb(0,0,0);font-weight: normal;font-style: normal;">请</span></j><j tm="1524216272100" na="小明"><span style="font-family: Tahoma;mso-ascii-theme-font: minor-fareast;color: rgb(0,0,0);font-weight: normal;font-style: normal;">亲</span></j><j tm="1524216279200" na="小明"><span style="font-family: Tahoma;mso-ascii-theme-font: minor-fareast;color: rgb(0,0,0);font-weight: normal;font-style: normal;">有什么需要帮助的</span></j><j tm="1524216287157" na="小明"><span style="font-family: Tahoma;mso-ascii-theme-font: minor-fareast;color: rgb(0,0,0);font-weight: normal;font-style: normal;">如果速度快解放可视对讲</span></j><j tm="1524216295826" na="小明1"><span style="font-family: Tahoma;mso-ascii-theme-font: minor-fareast;color: rgb(0,0,0);font-weight: normal;font-style: normal;">思考的价格</span></j><j tm="1524216296738" na="小明1"><span style="font-family: Tahoma;mso-ascii-theme-font: minor-fareast;color: rgb(0,0,0);font-weight: normal;font-style: normal;">富士康的报告</span></j><j tm="1524216297691" na="小明1"><span style="font-family: Tahoma;mso-ascii-theme-font: minor-fareast;color: rgb(0,0,0);font-weight: normal;font-style: normal;">
...全文
832 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
tianfang 2018-04-22
  • 打赏
  • 举报
回复
可以使用jsoup来做
tianfang 2018-04-22
  • 打赏
  • 举报
回复
使用html解析器 分离出信息,去掉格式

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧