Search and replace Selection (between Begin & End) in multiple files



  • Hello. I have a bunch of files that I want to change. Content that interests me is somewhere in the middle of each file. Let’s say that my text line is between 250 and 370. I just want to keep this text and delete the rest of other lines. Here’s how it looks.


    1 <! DOCTYPE html>
    2
    .

    250 <p class = “rating”> <img src = “images / test / stars.png” alt = “” /> </ p> ->
    .
    Word One TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT Last Word
    .
    370 <div id = ‘AdContainer_mayra_article_End_left_column’> </ div>
    .
    .
    500 </ html>


    I have two possibilities that I might ever do.

    Option 1. Select everything before Text and delete.

    Search and Select BEGIN: “<! DOCTYPE html>”
    Search and Select END “<p class =” rating “> <img src =” images / test / stars.png “alt =” “/> </ p> ->”
    Replace with 0 (Nothing)

    The same text after

    1. Select the entire text version which lies between

    Search and Select BEGIN: <p class = “rating”> <img src = “images / test / stars.png” alt = “” /> </ p> ->
    and
    Search and Select END <div id = ‘AdContainer_mayra_article_End_left_column’> </ div>
    DELETE ALL REST

    Someone help me?



  • Hello Neculai,

    Your problem should be easily achieved with regular expressions !

    However, as I suppose that your two lines 250 and 370, surrounding the text to keep, are different, in each concerned file, I need to know the general pattern of these two lines, in order to build the correct regexes for the S/R !

    Thanks you, in advance, for these additional informations !

    Best Regards,

    guy038



  • Ah, fortunately the RegEx cavalry (a.k.a. @guy038) noticed this thread. I consider the problem solved. ;-)


Log in to reply