html代码中使用正则匹配字符串
前置条件
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;">