• Login
Community
  • Login

Find value in line and delete that line and previous line?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 3 Posters 303 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.
  • P
    Phat Lix
    last edited by Dec 1, 2020, 8:40 PM

    Is it possible to find a value (or match a whole line) and if that value matches, delete that line and the previous line. The real question is can I delete the “previous” line?

    For example…

    Testing archive: archive01.zip    <--- this line will be deleted if next line matches
    Everything is Ok                  <-- match this line then delete this line and the previous line
    Testing archive: archive02.zip
    Sub items Errors: 1
    Testing archive: archive03.zip    <--- this line will be deleted if next line matches
    Everything is Ok                  <-- match this line then delete this line and the previous line
    Testing archive: archive04.zip
    Sub items Errors: 1
    Testing archive: archive05.zip    <--- this line will be deleted if next line matches
    Everything is Ok                  <-- match this line then delete this line and the previous line
    

    leaving me with…

    Testing archive: archive02.zip
    Sub items Errors: 1
    Testing archive: archive04.zip
    Sub items Errors: 1
    

    I would appreciate ANY help!

    Thank you.

    A 1 Reply Last reply Dec 1, 2020, 8:46 PM Reply Quote 1
    • A
      Alan Kilborn @Phat Lix
      last edited by Alan Kilborn Dec 1, 2020, 8:46 PM Dec 1, 2020, 8:46 PM

      @Phat-Lix

      Sure, something like this should work:

      find: (?-is)^.+\REverything is Ok\R
      repl: nothing
      search mode: Regular expression

      P 1 Reply Last reply Dec 1, 2020, 8:57 PM Reply Quote 5
      • P
        Phat Lix @Alan Kilborn
        last edited by Dec 1, 2020, 8:57 PM

        @Alan-Kilborn

        That is EXACTLY what I was looking for! Thank you very very much!

        I have tried so many interactions of similar syntax, but in the end… my regex just sucks! ;)

        Thank you again!

        P 1 Reply Last reply Dec 1, 2020, 9:01 PM Reply Quote 1
        • P
          PeterJones @Phat Lix
          last edited by Dec 1, 2020, 9:01 PM

          @Phat-Lix said in Find value in line and delete that line and previous line?:

          my regex just sucks! ;)

          FAQ on where to find regex documentation

          P 1 Reply Last reply Dec 1, 2020, 9:09 PM Reply Quote 1
          • P
            Phat Lix @PeterJones
            last edited by Dec 1, 2020, 9:09 PM

            @PeterJones

            Oh geez! That is a fantastic collection. Thank you.

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