Community
    • Login

    remove n lines before and after a specific text

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 2 Posters 1.6k 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.
    • Rockberto ManentiR
      Rockberto Manenti
      last edited by Rockberto Manenti

      Hi to all,
      I am not at all an expert in notepad ++ and above all in commands to find and replace words or phrases within a text. I would like to be able to delete, on several files, some lines before and after a line that contains a specific word (but leaving everything else before and after) . Example:

      text bla bla bla
      bla bla bla
      <actor>
      <name> Chuck Profus </name>
      <role> Drums </role>
      <order> 5 </order>
      <thumb></thumb>
      </actor>
      bla bla bla
      bla bla bla

      I’d like to delete 4 lines before and 1 after <thumb></thumb>
      and must become in all the files:

      text bla bla bla
      bla bla bla
      <thumb></thumb>
      bla bla bla
      bla bla bla

      It can be done? Thanks in advance

      1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn
        last edited by

        @Rockberto-Manenti

        You might try:

        Find: (?-s)(?:.*?\R){4}^(.*?<thumb></thumb>.*?\R).*?\R
        Repl: ${1}
        Search mode: Regular expression

        1 Reply Last reply Reply Quote 1
        • Rockberto ManentiR
          Rockberto Manenti
          last edited by

          @Alan-Kilborn said in remove n lines before and after a specific text:

          ${1}

          seems that it works!!! many thanks!
          now I try on multiple files

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