Community
    • Login

    How to find and select all words between select words?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    12 Posts 5 Posters 29.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.
    • Dawn BrockmanD
      Dawn Brockman
      last edited by

      I have been using the “media Companion” to find cover art for my movies as well as plots for the movies as well. I don’t use media programs I just use “Windows 10” and “File Explorer”. So I change the cover art and then I write the plot in the comments section and I also add the Genre.

      So here is the issue when I open the notepad++ program to find the “Plot” and the “Genres” the plot starts with <plot> and then the plot is written in there and then it says </plot> is there a way to select all the text between <plot> and </plot> automatically. Because sometimes the text is pretty long and hard to copy by just scrolling over it and highlighting it. I already know how to use the replace from the search. But I’m not to sure if this is even possible. I so please tell me know thank you.

      1 Reply Last reply Reply Quote 0
      • Terry RT
        Terry R
        last edited by Terry R

        @Dawn-Brockman said in How to find and select all words between select words?:

        is there a way to select all the text between <plot> and </plot> automatically

        There is a method, it involves using “regular expressions”, or regex for short.

        So once the file is opened in Notepad++, use the Find function. Set search mode to regular expression and use the following.
        Find What:(?s)(?<=plot>)(.+?)(?=</plot>)
        click on the Find Next button. The text you want is highlighted.

        If you need an explanation of the syntax of the regex:
        (?s) … Identifies any DOT character as also containing the line feed characters (\r and \n)
        (?<=plot>) … This positions the cursor so the preceding characters are plot>
        (.+?) … This means grab characters lazily until … (The DOT character means any character)
        (?=</plot>) … we see immediately ahead of us the </plot> sequence.

        Terry

        1 Reply Last reply Reply Quote 3
        • Dawn BrockmanD
          Dawn Brockman
          last edited by

          This did the trick and I was wondering if there was a way to select it and not just highlight it. I do see it all grayed out but I was wondering if there is a easier way then to Hold Shift and then Left Click the text I want to select.

          Terry RT 1 Reply Last reply Reply Quote 0
          • Terry RT
            Terry R @Dawn Brockman
            last edited by Terry R

            @Dawn-Brockman said in How to find and select all words between select words?:

            I do see it all grayed out but I was wondering if there is a easier way then to Hold Shift and then Left Click the text I want to select.

            Sorry, I don’t know if you mean this to be a new question or follow on from previous.

            So once it is highlighted close the Find window and then press Ctrl-C (this will pickup the highlighted text). Go to a new tab or file and position the cursor before Ctrl-V (paste).

            Understand it will retain the line formatting as previous, so if multiple lines in the original, then the copy will look exactly the same with indents, line feeds etc.

            Terry

            1 Reply Last reply Reply Quote 2
            • Dawn BrockmanD
              Dawn Brockman
              last edited by

              Okay now finding the “Plot” area is much easier then before and I didn’t know that once the text was highlighted I didn’t need to re-highlight it again once I found the text.

              I have been using Ctrl+c and Ctrl+v for a while now I just thought I need to re-select it and then copy it and then paste it. But knowing that by finding it its already highlighted and selected for me. Once I actually copy it with Ctrl+c it gets much easier.

              thank you for all the help with this. Now all I need to do is copy the shortcut you gave me and place it into a file and keep it onto my desktop. Do you know of any other tips like this one. Or of a site with tutorials so I can take some tips and place them into a file and keep it on my PC. So I could have some tips at my finger tips so to speak.

              Alan KilbornA 1 Reply Last reply Reply Quote 1
              • Terry RT
                Terry R
                last edited by

                @Dawn-Brockman said in How to find and select all words between select words?:

                Do you know of any other tips like this one.

                Well most of the members who have used Notepad++ (often shortened to NPP) for a while will have methods that they use to help them. Unfortunately there isn’t a repository of these that I’m aware of.

                But if you have an issue I would suggest searching on this forum first. If you can’t find an answer just post your question. Most of the members will willingly provide their ideas (and solutions) if they think it will help, as I did.

                There is an online manual for NPP and references to regular expressions in the FAQ section, so look there as well.

                Terry

                1 Reply Last reply Reply Quote 0
                • guy038G
                  guy038
                  last edited by guy038

                  Hello, @dawn-brockman, @terry-R and All,

                  May be, I misunderstand something obvious, but there is an easy way to get a list of all the <plot>•••••</plot>, at once, in a new file :

                  • Open the Mark dialog ( Ctrl + M )

                  • SEARCH (?s-i)(?<=<plot>).+?(?=</plot>)

                  • Tick the two options Purge for each search and Wrap around

                  • Un-tick all other box options

                  • Select the Regular expression search mode

                  • Click on the Mark All button

                  => The <plot>•••••</plot> areas shouild be hightlighted in red !

                  • Now, click on the Copy Marked Text button

                  • Open a new file ( Ctrl + N )

                  • Paste the clipboard contents ( Ctrl + V )

                  Voila !

                  In addition, as you’re currently doing a multi-lines regex search, the Copy Marked Text feature automatically inserts a four-dashes separation line ( ---- ) between each occurrence ;-))

                  Best Regards,

                  guy038

                  1 Reply Last reply Reply Quote 1
                  • Terry RT
                    Terry R
                    last edited by

                    @guy038 said in How to find and select all words between select words?:

                    easy way to get a list of all the <plot>•••••</plot>

                    I interpreted the OP’s request as only 1 instance of the text to be selected in the file.

                    Terry

                    1 Reply Last reply Reply Quote 0
                    • Alan KilbornA
                      Alan Kilborn @Dawn Brockman
                      last edited by

                      @Dawn-Brockman said in How to find and select all words between select words?:

                      Now all I need to do is copy the shortcut you gave me and place it into a file and keep it onto my desktop

                      Instead of that you could make a macro out of it.

                      • set up your search but don’t execute it yet (or execute it to test it!)
                      • leave Find window open
                      • do Macro menu then Start Recording
                      • now execute the search you’ve previously set up
                      • do Macro menu then Stop Recording
                      • do Macro menu then Save Currently Recorded Macro… and name your macro

                      Now the name you gave the macro will appear in the lower part of the Macro menu, and you can execute it by selecting it.

                      Dawn BrockmanD 1 Reply Last reply Reply Quote 3
                      • Dawn BrockmanD
                        Dawn Brockman @Alan Kilborn
                        last edited by

                        @Alan-Kilborn The Macro trick worked great thank you. Its like a way to cheat and still not need to re-paste the code every time I change the “Search”. Thank You!

                        1 Reply Last reply Reply Quote 2
                        • Marcin KucharskiM
                          Marcin Kucharski
                          last edited by

                          Hi! I have a similar problem. I need to extract a part of text between strings:
                          *** text 1 ***
                          and
                          *** text 2 ***
                          The problem is that text 1 and text 2 is different in each of thousands files.
                          Another problem is that *** should be interpreted as an actual asterisk not a wildcard. Can someone help? I can also use PowerShell but I don’t know how to write a script :|

                          Alan KilbornA 1 Reply Last reply Reply Quote 0
                          • Alan KilbornA
                            Alan Kilborn @Marcin Kucharski
                            last edited by

                            @marcin-kucharski

                            Don’t ask the same question in 2 threads; you asked the same question HERE

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