Community
    • Login

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

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 3 Posters 3.0k Views 2 Watching
    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.
    • Neculai I. FantanaruN Offline
      Neculai I. Fantanaru
      last edited by 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 Reply Last reply Reply Quote 0
      • guy038G Online
        guy038
        last edited by

        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 Reply Last reply Reply Quote 0
        • Jan SchreiberJ Offline
          Jan Schreiber
          last edited by

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

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors