Selecting text between tags and saving to another document
-
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
-
@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:

Terry
-
@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
-
This was exactly what I was looking for, I sure do thank you. Sorry, sometimes my head cannot figure out certain things.
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