Community
    • 登入

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

    已排程 已置頂 已鎖定 已移動 Help wanted · · · – – – · · ·
    5 貼文 3 Posters 331 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • Phat LixP
      Phat Lix
      最後由 編輯

      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.

      Alan KilbornA 1 條回覆 最後回覆 回覆 引用 1
      • Alan KilbornA
        Alan Kilborn @Phat Lix
        最後由 Alan Kilborn 編輯

        @Phat-Lix

        Sure, something like this should work:

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

        Phat LixP 1 條回覆 最後回覆 回覆 引用 5
        • Phat LixP
          Phat Lix @Alan Kilborn
          最後由 編輯

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

          PeterJonesP 1 條回覆 最後回覆 回覆 引用 1
          • PeterJonesP
            PeterJones @Phat Lix
            最後由 編輯

            @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

            Phat LixP 1 條回覆 最後回覆 回覆 引用 1
            • Phat LixP
              Phat Lix @PeterJones
              最後由 編輯

              @PeterJones

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

              1 條回覆 最後回覆 回覆 引用 2
              • 第一個貼文
                最後的貼文
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors