<table>asd</table>\r\n<table>序号</table>
<table>序号</table>
.
不能匹配换行符号)<table attr="asd">asd</table>
<table><tr height="29"><td>序号</td></tr><tr height="29"><td>1</td></tr></table>
<table((?!</table>)[\s\S])*序号[\s\S]*</table>
<table attr="asd">asd</table>
<table><table attr="asd">asd</table><tr height="29"><td>序号</td></tr><tr height="29"><td>1</td></tr></table>
b=re.findall(r"<table>.*<\/table>$",a)
>>> b
['<table>序号</table>']
是想要匹配 <table>汉字</table> 吗?
如果是的话,请看答案:
<table>[\u4e00-\u9fa5]*</table>
效果:
如果复合,望采纳~
str = 原始字符串
Reg = /你要提取的字符串/
Arr = str.match(Reg)
a = '''<table attr="asd">序号</table>
<table></table>
<table><table attr="asd">asd</table><tr height="29"><td>序号</td></tr><tr height="29"><td>1</td></tr></table>'''
类似这种,你想要保留
<table attr="asd">序号</table>
和
<table><table attr="asd">asd</table><tr height="29"><td>序号</td></tr><tr height="29"><td>1</td></tr></table>
中间多余的table不动?