Search code examples
regexnotepad++

Bookmark specific word line and one line before each bookmark


I have a list like following:

  <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>

Now I want to bookmark .png" alt lines and one line before of each bookmarked lines in notepad++ by regex.

I tried following Regular expressions but not worked:

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

Where is my problem?


Solution

  • In all your patterns you are matching the line after it.

    If you want the line before it, it should be the other way around. You could capture the line if that is necessary and you only have to match the next line to the alt part.

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

    See a regex demo.