• Login
Community
  • Login

Find Begin/End setting

Scheduled Pinned Locked Moved General Discussion
notes
21 Posts 5 Posters 7.9k 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.
  • J
    Javier Rivas
    last edited by Javier Rivas Jan 15, 2021, 6:46 AM Jan 15, 2021, 6:44 AM

    Ok, so I would like to know, if notepad++ can use a find start, find end

    So I have a txt files with 50,000 rows, and on each row I have 4 letter codes

    I would like to know, and how if possible to select between 2 sets of codes

    Keep in mind, holding shift, and scrolling down is not an option, it’s way to long

    So in my text files I have
    Cod1
    Xid2
    Xid3
    Xid4
    Xid5
    Cod2

    I’m looking for anything that can find both Cod1 and Cod2, highlight everything between so that I can copy or cut that out to another notepad

    E A 2 Replies Last reply Jan 15, 2021, 12:16 PM Reply Quote 0
    • E
      Ekopalypse @Javier Rivas
      last edited by Jan 15, 2021, 12:16 PM

      @Javier-Rivas

      If this is your real data then you can do a regular expression search (?<=Cod1).+(?=Cod2)

      4a8f0731-a8b5-4949-8ae5-35ee08eb2d9e-image.png

      J 1 Reply Last reply Jan 15, 2021, 6:15 PM Reply Quote 1
      • A
        Alan Kilborn @Javier Rivas
        last edited by Jan 15, 2021, 12:55 PM

        @Javier-Rivas said in Find Begin/End setting:

        Keep in mind, holding shift, and scrolling down is not an option, it’s way to long

        Check out the Edit menu’s Begin/End select feature. Invoke it once to set a “beginning” position (you get no visual indication that you’ve done this). Sometime later, when you are somewhere vastly different from you starting point, invoke that same command again. This looks up your previously-set beginning position and creates selected text between there and your current position.

        1 Reply Last reply Reply Quote 1
        • G
          guy038
          last edited by guy038 Jan 15, 2021, 1:15 PM Jan 15, 2021, 1:14 PM

          Hello, @javier-Rivas, @ekopalypse and @alan-kilborn and All,

          I think that a more accurate regex would be :

          MARK (?s-i)^Cod1\R\K.+?(?=^Cod2\R)

          Because :

          • The (?-i) ensures that search of the limits Cod1 and Cod2 are done with case respect

          • The lazy quantifier +? is needed if several sections Cod1.......Cod2 exist in a same file

          • The start of line assertion ^ and the EOL characters \R ensure, for instance, that the line Cod2 will not be matched, either, in lines XXXCod2, Cod2XXX or XXXCod2XXX

          • The \R syntax, after Cod1, prevents from marking the line Cod1, too

          Best Regards,

          guy038

          J 1 Reply Last reply Jan 15, 2021, 5:52 PM Reply Quote 1
          • A
            Alan Kilborn
            last edited by Jan 15, 2021, 1:38 PM

            @Javier-Rivas

            so that I can copy … that out to another notepad

            If you highlight the text using either @Ekopalypse or @guy038 methods, you’ll want to use the Copy Marked Text button after.

            … or cut …

            There is no Cut Marked Text capability – maybe there should be?

            J 1 Reply Last reply Jan 16, 2021, 6:07 AM Reply Quote 2
            • C
              carypt
              last edited by Jan 15, 2021, 3:10 PM

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • J
                Javier Rivas @guy038
                last edited by Jan 15, 2021, 5:52 PM

                @guy038 do I need to download a plugin. Because my Mark screen does not look like the one in the screen shot

                A 1 Reply Last reply Jan 15, 2021, 5:57 PM Reply Quote 0
                • A
                  Alan Kilborn @Javier Rivas
                  last edited by Jan 15, 2021, 5:57 PM

                  @Javier-Rivas

                  You just need N++ version 7.9.1 or greater.

                  J 1 Reply Last reply Jan 15, 2021, 6:07 PM Reply Quote 0
                  • J
                    Javier Rivas @Alan Kilborn
                    last edited by Jan 15, 2021, 6:07 PM

                    @Alan-Kilborn great, but the mark didn’t work, the data I used is an example, but to test the regex, I made a txt file and added Cod1 and many data between, and add Cod2. I pressed on all and found nothing. Marked nothing

                    J 1 Reply Last reply Jan 15, 2021, 6:12 PM Reply Quote 0
                    • J
                      Javier Rivas @Javier Rivas
                      last edited by Jan 15, 2021, 6:12 PM

                      @Javier-Rivas OK the first regex worked, now to test on my real txt file

                      A 1 Reply Last reply Jan 15, 2021, 6:12 PM Reply Quote 0
                      • A
                        Alan Kilborn @Javier Rivas
                        last edited by Jan 15, 2021, 6:12 PM

                        @Javier-Rivas said in Find Begin/End setting:

                        @Javier-Rivas OK the first regex worked, now to test on my real txt file

                        Are you talking to yourself? :-)
                        Convincing yourself that it really does work?? :-)

                        J 1 Reply Last reply Jan 15, 2021, 10:32 PM Reply Quote 0
                        • J
                          Javier Rivas @Ekopalypse
                          last edited by Jan 15, 2021, 6:15 PM

                          @Ekopalypse OK your code works, question, could it also highly the Cod 1 and Cod2, I know I said between, but I thought it would find the Cod1 and Cod2 and include it as well

                          A 1 Reply Last reply Jan 15, 2021, 6:16 PM Reply Quote 0
                          • A
                            Alan Kilborn @Javier Rivas
                            last edited by Alan Kilborn Jan 15, 2021, 6:17 PM Jan 15, 2021, 6:16 PM

                            @Javier-Rivas

                            could it also highly the Cod 1 and Cod2, I know I said between, but I thought it would find the Cod1 and Cod2 and include it

                            find: Cod1.+?Cod2

                            J 1 Reply Last reply Jan 15, 2021, 6:19 PM Reply Quote 1
                            • J
                              Javier Rivas @Alan Kilborn
                              last edited by Jan 15, 2021, 6:19 PM

                              @Alan-Kilborn Perfect

                              A 1 Reply Last reply Jan 15, 2021, 6:22 PM Reply Quote 2
                              • A
                                Alan Kilborn @Javier Rivas
                                last edited by Jan 15, 2021, 6:22 PM

                                @Javier-Rivas

                                Learn what it does, for yourself for the future:

                                • match Cod1 exactly
                                • .+? match any single character (the dot means “any single”), one or more times (the + means 1+ times), but as few times as needed (the ? specifies that)
                                • match Cod2 exactly

                                All 3 of these things must exist for you to have an overall match.

                                J 1 Reply Last reply Jan 15, 2021, 10:28 PM Reply Quote 1
                                • J
                                  Javier Rivas @Alan Kilborn
                                  last edited by Javier Rivas Jan 15, 2021, 10:29 PM Jan 15, 2021, 10:28 PM

                                  @Alan-Kilborn OK, so I have improved the code search to my use so here is my original search
                                  (?= "caup).+(?= "cues) < — notices the spacing and I removed the <

                                  first to find is “caup”, and it starts with 2 spaces in front of it
                                  last to find is “cues”, and it needs to stop 2 spaces before the “cues”

                                  —“caup”: < ---- it highlights the spaces and the code
                                  -{
                                  -adad
                                  -adasd
                                  -asdad
                                  -}
                                  ], < ------- it stops right here
                                  —“cues”: < ----- it ignores the spaces and the code

                                  so now it’s perfect to my standards

                                  1 Reply Last reply Reply Quote 3
                                  • J
                                    Javier Rivas @Alan Kilborn
                                    last edited by Jan 15, 2021, 10:32 PM

                                    @Alan-Kilborn Yes, I call it motivation…lmao
                                    Yea, I wanted to add a comment and I clicked on reply to myself…hahahaha

                                    1 Reply Last reply Reply Quote 3
                                    • J
                                      Javier Rivas @Alan Kilborn
                                      last edited by Jan 16, 2021, 6:07 AM

                                      @Alan-Kilborn there should be a cut mark and and replace mark that would be awesome

                                      A 1 Reply Last reply Jan 16, 2021, 12:28 PM Reply Quote 0
                                      • A
                                        Alan Kilborn @Javier Rivas
                                        last edited by Jan 16, 2021, 12:28 PM

                                        @Javier-Rivas said in Find Begin/End setting:

                                        there should be a cut mark and and replace mark that would be awesome

                                        That would be nice I suppose, but in practice it is not so bad without it.

                                        I’d like to see two separate commands: Begin Select and End Select. That way it would be easier to abort a begin-point by setting a new one (if you realize you’ve made a mistake in setting the origin), and it could also be a reminder in the menu that you haven’t yet set the begin point (Begin Select would be enabled and End Select would be disabled).

                                        BUT…it is definitely OK the way it currently works. And a downside of two commands is that using it from a shortcut would require two shortcuts to be allocated.

                                        Speaking of shortcuts, one thing that is lacking is tying this handy functionality to a shortcut by default. I tie mine to Ctrl+b.

                                        1 Reply Last reply Reply Quote 0
                                        • G
                                          guy038
                                          last edited by guy038 Jan 16, 2021, 1:11 PM Jan 16, 2021, 1:09 PM

                                          Hi, @javier-rivas, @ekopalypse and @alan-kilborn and All,

                                          @javier-rivas, taking in account your additional information, my regex becomes :

                                          MARK (?s-i)^\x20\x20"caup":.+?(?=^\x20\x20"cues":)

                                          This regex :

                                          • Matches the literal string "caup":, preceded with two space characters ( because of \x20\x20 ) beginning a line, ( because of ^ ), with this exact case ( because of the (?-i) modifier )

                                          • Followed with the smallest ( because of ? ) non-null ( because of + ) range of any character ( because of (?s) modifier )…

                                          • But ONLY IF followed with the literal string "cues":, preceded with two space characters ( because of \x20\x20 ) beginning a line, ( because of ^ ), with this exact case ( because of the (?-i) modifier ).

                                          Note that the (?=......) syntax is a look-ahead structure, in other words a condition, which must be true in order the present match, so far, to be valid but which is never part of the overall match


                                          Thus, in the text below :

                                            "caup":
                                          -{
                                          -adad
                                          -adasd
                                          -asdad
                                          -}
                                          ],
                                            "cues":
                                          

                                          It would mark and bookmark all the lines but the last one !

                                          Cheers,

                                          guy038

                                          J 1 Reply Last reply Jan 16, 2021, 9:16 PM Reply Quote 1
                                          8 out of 21
                                          • First post
                                            8/21
                                            Last post
                                          The Community of users of the Notepad++ text editor.
                                          Powered by NodeBB | Contributors