我使用powerGrep查找这些实例的实例:
第1项:
<td class="danish">kat
<?php audioButton("../../audio/words/dog","dog");?></td>但在我的档案中也有这样的例子:
区块2
<td class="danish">kat</td>
<td><?php audioButton("../../audio/words/dog","dog");?></td>我只想找到第1块,而不是第2块。
我试过使用(?!),如在
.*<td class(.*?)>(.*)(?!</td>)
.*<\?php audioButton\("(.*)/.*",".*"\);.*\?></td> 我是否可以从搜索中排除</td>标记,从而忽略块2?
发布于 2016-09-13 03:35:05
我不知道为什么您真的希望只匹配第一个单元格标记,但要执行此操作,您可以尝试:
带有<td[^>]*>\s*(?:.(?!</td>))+\s*<\?php audioButton\("[^"]*/(.+?)","(.*?)"\);.*?\?>.*?</td>标志的g。
看到它在这里工作:https://regex101.com/r/tI4rL4/1
编辑
您还可以在这里看到将dog替换为cat:https://regex101.com/r/tI4rL4/2
它可能不是完美的,因为这个问题有点模糊,但它有效。如果你需要改进一点,或调整或需要一点解释,你可以问我!
https://stackoverflow.com/questions/39460378
复制相似问题