regex 书签特定字行和每个书签前一行

6uxekuva  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(70)

我有一个列表如下:

<th class="News">20</th>
  <td class="News"><a href="vector">Vector</a></td>
  <td class="News" style="text-align: right" title="Yesterday: 182">181<img src="/web/20040929104305im_/http://distrowatch.com/images/other/adown.png" alt=">" title="Yesterday: 182"></td>
</tr>
<tr>
  <th class="News">21</th>
  <td class="News"><a href="turbolinux">Turbolinux</a></td>
  <td class="News" style="text-align: right" title="Yesterday: 176">177<img src="/web/20040929104305im_/http://distrowatch.com/images/other/aup.png" alt="<" title="Yesterday: 176"></td>
</tr>
<tr>
  <th class="News">22</th>
  <td class="News"><a href="gnoppix">Gnoppix</a></td>
  <td class="News" style="text-align: right" title="Yesterday: 171">171<img src="/web/20040929104305im_/http://distrowatch.com/images/other/alevel.png" alt="=" title="Yesterday: 171"></td>
</tr>
<tr>
  <th class="News">23</th>
  <td class="News"><a href="aurox">Aurox</a></td>
  <td class="News" style="text-align: right" title="Yesterday: 172">171<img src="/web/20040929104305im_/http://distrowatch.com/images/other/adown.png" alt=">" title="Yesterday: 172"></td>
</tr>
<tr>
  <th class="News">24</th>
  <td class="News"><a href="buffalo">Buffalo</a></td>
  <td class="News" style="text-align: right" title="Yesterday: 163">162<img src="/web/20040929104305im_/http://distrowatch.com/images/other/adown.png" alt=">" title="Yesterday: 163"></td>
</tr>

字符串
现在我想用正则表达式在notepad++中标记.png" alt行和每个标记行的前一行
我尝试使用正则表达式,但没有成功:

^.+\.png" alt.*\R\K.+
^.+\.png" alt.*$\R(.+)$
^.+\.png" alt.*$\R\K^.+$
^.+\.png" alt.*$\R
^.+\.png" alt.*$\R^.+$


我的问题在哪里?

yzxexxkh

yzxexxkh1#

在你所有的模式中,你都在匹配它后面的线。
如果你想要它前面的那一行,它应该反过来。如果有必要的话,你可以捕获这一行,你只需要将下一行与alt部分匹配。

(.*)\R.+\.png" alt\b

字符串
参见regex demo

相关问题