1 获取html中某一标签到某一标签中间的内容,比如你想获取<table></table>中间的字符串,如果不好确定目标,或者有很多无关的字符,就要用正则筛选一下。
取一个div标签中间的内容:
<div class=\"jwts_tabbertab\" title.*>[\s\S]*?</div>
取出带有class属性的table标签内容的正则表达式
<table class(.*)>.*?</table>
取出a标签的值和a标签中的内容
<td>(<a href.*?>(.*?)</a>)</td>
table:
<table.*?>[\s\S]*<\/table>
或
<table.*?>[\s\S]*?<\/table>
常用网页标签:
获取正则表达式匹配网页标签内容_qq_40604853的博客-CSDN博客_正则表达式匹配标签内容 https://blog.csdn.net/qq_40604853/article/details/82699520
常用匹配场景:https://blog.csdn.net/moshowgame/article/details/94447007
关于匹配sql:
https://github.com/moshowgame/SpringBootCodeGenerator/issues/22
结合java分组函数:
相似:
-
a.*?b就是a开始b结束的匹配
-
如果要限制是一行的开头和末尾的话,就是^a.*?b$
好用的正则表达式小工具:
https://deerchao.cn/tutorials/regex/regex.htm
参考博客:
正则表达式匹配html标签table_whilelie的专栏-CSDN博客_匹配html table标记的正则表达式 https://blog.csdn.net/whilelie/article/details/21025751