remove n lines before and after a specific text



  • 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



  • @Rockberto-Manenti

    You might try:

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



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


Log in to reply