Community
    • Login

    Selecting text between tags and saving to another document

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    xml
    4 Posts 2 Posters 5.7k 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.
    • Devlin DeaneD
      Devlin Deane
      last edited by

      I am sorry but I couldnt find a answer to this.

      I am trying to select all the text between the <key> </key> tags in a xml file only and then of course past them to another as just regular lines. An example of the text is below. Thanks.

      </StorageClass></Contents><Contents><Key>0ef5858c-4489-4acb-a1c8-ace1a40cf7f4.jpg</Key><LastModified>2020-06-25T07:51:57.000Z</LastModified><ETag>“eeb215105af23214f624832c7a3bd788”</ETag><Size>3862804</Size><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>0fe8d604-bc17-4592-a106-57314cebf7d1.gif</Key><LastModified>2020-06-24T03:50:42.000Z</LastModified><ETag>“ca77dfa40f9375ae9ca5b83a84fd6f8a”</ETag><Size>125898</Size><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>104205bb-649a-4bc5-9d2c-151ed4d954cf.gif</Key><LastModified>2020-06-25T21:23:43.000Z</LastModified><ETag>“18b7be284026a9a21462b70fcdae57ae”</ETag><Size>1787248</Size><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>10b5fbc9-de5c-4207-928d-9ba008730442.jpg</Key><LastModified>2020-12-11T15:31:36.000Z</LastModified><ETag>“5e5649097fcc2e5515760aa441eb72f3”</ETag><Size>88846</Size><StorageClass>STANDARD

      Terry RT 2 Replies Last reply Reply Quote 0
      • Terry RT
        Terry R @Devlin Deane
        last edited by

        @devlin-deane said in Selecting text between tags and saving to another document:

        I am trying to select all the text between the <key> </key> tags in a xml file only and then of course past them to another as just regular lines.

        I would suggest using the “Mark” function, type into the Find What field:
        (?-s)<key>.+?</key> and have search mode set to “regular expression”. Once you have “marked all” text, then the other option there is called “copy marked text”. Click that, create a new empty tab and paste. Note I have (?-s) in my regular expression. This prevents trying to cross lines, however you could remove that if you wanted, it shouldn’t affect the outcome if ALL your <key>…</key> tags are correctly set up.

        See my example of the first step below:
        e9efca92-adfc-4afc-8abc-ceab9d304033-image.png

        Terry

        1 Reply Last reply Reply Quote 4
        • Terry RT
          Terry R @Devlin Deane
          last edited by Terry R

          @devlin-deane said in Selecting text between tags and saving to another document:

          I am trying to select all the text between the <key> </key> tags in a xml file

          I should add that this ALSO selects the tags at each end. It is a simple matter to remove those by using the replace function, I’ll leave that up to you. I could also have created a slightly different regular expression to exclude those but I kept it simple. Often when learning you want to get the concept of the simple ways first, even if it might take several more steps. Then later on combine those in a harder expression.

          Terry

          Devlin DeaneD 1 Reply Last reply Reply Quote 1
          • Devlin DeaneD
            Devlin Deane @Terry R
            last edited by

            @terry-r

            This was exactly what I was looking for, I sure do thank you. Sorry, sometimes my head cannot figure out certain things.

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