这里有这样一个问题,我们会遇到这样的情况:
(1)((3) a>)(4) td>
这里的2,3位置决定的a标签可能存在,而1,4的位置可能由内容也可能没有内容,能不能用一个正则表达式让不管a标签存在与否都匹配出1,4位置的内容呢
比如
this is not empty
this is not empty
this is not empty>this is not empty
这里有一个例子
(.+?)(
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
哈哈,这要是php就简单了。直接过滤标签完事了。然而这PY
看你的意思是要从表格里面,提取文字。。
那么可以
<td>(.*?)(<.+?>)*(.*?)</td>也可以分步,先
<td>(.+?)</td>把内容取出来。然后把<.+?>全替换空。或者。。用回你的正则
<td>(.+?)(<a href="(.*?)>(.*?)</a>)?(.+?)</td>+代表匹配至少1次,而*代表0次或者更多