Community
    • 登入

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

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

      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?

      1 條回覆 最後回覆 回覆 引用 0
      • guy038G
        guy038
        最後由 編輯

        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

        1 條回覆 最後回覆 回覆 引用 0
        • Jan SchreiberJ
          Jan Schreiber
          最後由 編輯

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

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