Community
    • Login

    RegEx Remove the Last Match Only

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 3 Posters 615 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • NZ SelectN
      NZ Select
      last edited by

      
            </td> </td
            <td> </td
              <p>ITEMS</p>
            </td> </td
            <td>&nbsp;</td>
            <td> </td
              <p>INDEX</p>
            </td> </td
          </tr> </tr
          <br> <br>
           
      

      Is it possible to create a RegEx code to capture the last </td ?

      My current code is

      \ </td.*?
      

      It matches the first td as well, such as
      </td> </td

      Thanks in advance!

      astrosofistaA Alan KilbornA 2 Replies Last reply Reply Quote 0
      • astrosofistaA
        astrosofista @NZ Select
        last edited by

        @NZ-Select

        Yes, by taking advantage of the greediness of * symbol. Try the following:

        Search: (?s).*\K</td.*?
        Replace: [leave empty]
        

        Put the caret at the very beginning of the document, select the Regular Expression mode and click only on Replace All.

        Have fun!

        1 Reply Last reply Reply Quote 1
        • Alan KilbornA
          Alan Kilborn @NZ Select
          last edited by

          @NZ-Select :

          There’s a technique to find the last match in a file, presented HERE. You might give that a try.

          1 Reply Last reply Reply Quote 1
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors