• Login
Community
  • Login

Shift+F3 no more works

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
15 Posts 7 Posters 1.5k 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.
  • A
    Alan Kilborn @mkupper
    last edited by Sep 30, 2023, 3:14 PM

    @mkupper said in Shift+F3 no more works:

    it’s best to dial up your favorite mysterious music when attempting to discover edge conditions of what happens if you perform regular expressions, backwards.

    @PeterJones Maybe the user manual should provide an example?

    P 1 Reply Last reply Sep 30, 2023, 7:02 PM Reply Quote 2
    • P
      PeterJones @Alan Kilborn
      last edited by Sep 30, 2023, 7:02 PM

      @Alan-Kilborn said in Shift+F3 no more works:

      Maybe the user manual should provide an example?

      If someone were to create an issue in the UM repo , and provide an example regex that will not work as expected in backwards mode, I could add it into the manual. (But I don’t know how to craft a simple regex that would have an obvious meaning when searching forward, but mess up when searching backward, so I cannot come up with an example myself.)

      A 1 Reply Last reply Sep 30, 2023, 7:18 PM Reply Quote 1
      • A
        Alan Kilborn @PeterJones
        last edited by Sep 30, 2023, 7:18 PM

        @PeterJones

        It seems like there should be one when that “power user” mode thing was added to Notepad++. I’ll see if I can find it.

        1 Reply Last reply Reply Quote 0
        • G
          guy038
          last edited by guy038 Sep 30, 2023, 8:11 PM Sep 30, 2023, 7:22 PM

          Hi, @reinhardhofmann, @alan-kilborn, @mkupper and All,

          Hi, All, do you know that, even with the regexBackward4PowerUser enabled, there are still some cases where the backward regex search do not work ?

          For example, in a new tab, copy this text :

          This is à test
          This is à second test
          This is à third test
          This is à final test
          

          Note that, in each line, I replaced the indefinite English article a with the French accentuated letter à !

          • Move to the beginning of this file

          • Select the à letter, in line 1

          • Open the search dialog ( Ctrl + F )

          • Tick the Wrap around box option

          • Select the Regular expression search mode

          • Hit on the Find Next button

          => The à char, in line 2, should be selected

          • Close the Find dilaog ( Esc )

          • Hit the F3 key

          => Again, the à char, in line 3, should be selected

          • Now, use the Shift+ F3 shortcut => Nothing happened ???

          ( Of course, I suppose that you do have the string regexBackward4PowerUser="yes", in your active config.xml file ! )


          This happens ONLY IF :

          • Your search mode is Regular expression

          • The searched character is over \x{007F}

          • The current encoding file is an Unicode one : UTF-8, UTF-8-BOM, UTF-16 BE BOM or UTF-16 lE BOM


          Luckily, I’ve found a way around this limitation. The rule is :

          When a backward regex do not work as expected, simply add the regex string (?=(?s).) at the end of the present regex !

          Thus, if we, now, search for the regex à(?=(?s).), you should be able to search backwards or forwards, at any time !

          Best Regards,

          guy038

          A 1 Reply Last reply Sep 30, 2023, 10:55 PM Reply Quote 1
          • G
            guy038
            last edited by guy038 Sep 30, 2023, 8:21 PM Sep 30, 2023, 8:06 PM

            Hello, @peterjones, and All,

            Regarding examples to include in the Official documentation, here are two examples which :

            • Do not work at all, in backward direction, if the regexBackward4PowerUser is not set

            • Else, allows the regex backward search but gives right results in the first example only


            Let’s consider the following text, where I included, this time, the classical English a article :

            This is a test
            This is a second test
            This is a third test
            This is a final test
            
            • If the regexBackward4PowerUser option is enabled ( "yes" ) :

              • The regex (?-s)i.*te does find the greatest range of characters, between a i letter and the te string in BOTH forward AND backward search

              • The regex (?s)i.+ does find the greatest range of chars, beginning with an i letter, in forward search BUT finds multiple wrong occurrences when used in backward direction !

            • If the regexBackward4PowerUser option is disabled ( "no" ) :

              • The two regexes works as expected in forward direction and CANNOT be used in backward direction

            BR

            guy038

            A 1 Reply Last reply Sep 30, 2023, 10:58 PM Reply Quote 2
            • A
              Alan Kilborn @guy038
              last edited by Sep 30, 2023, 10:55 PM

              @guy038

              even with the regexBackward4PowerUser enabled, there are still some cases where the backward regex search do not work ?

              YES! No one ever said all regexes work fine moving backward in this mode. If they did, there’d be no need for the mode to exist at all!

              1 Reply Last reply Reply Quote 0
              • A
                Alan Kilborn @guy038
                last edited by Sep 30, 2023, 10:58 PM

                @guy038 said in Shift+F3 no more works:

                The regex (?s)i.+ does find the greatest range of chars, beginning with an i letter, in forward search BUT finds multiple wrong occurrences when used in backward direction !

                What about (?s)i.+(?=.) for this case?
                (I’m away from my Notepad++ PC right now so I can’t try it)

                1 Reply Last reply Reply Quote 0
                • M
                  Mark Olson
                  last edited by Oct 1, 2023, 12:54 AM

                  Nobody has talked about trying to actually solve the issues with backward regex searching, but it seems to me like a potential solution might be along these lines:

                  when someone regex-searches backwards:
                      if need-to-re-search-file:
                          regex-search the entire file starting from the beginning
                      find the last match before the current position
                  when someone edits a file or changes the regex to be searched:
                      set need-to-re-search-file = true
                  

                  Obviously I’m not saying this would be easy and I fully expect it would be very hard to implement, but what do people think about that idea?

                  C 1 Reply Last reply Oct 1, 2023, 1:47 AM Reply Quote 1
                  • C
                    Coises @Mark Olson
                    last edited by Oct 1, 2023, 1:47 AM

                    @Mark-Olson said in Shift+F3 no more works:

                    Nobody has talked about trying to actually solve the issues with backward regex searching

                    Perhaps I have missed it, but I have not yet seen the issues precisely defined. In particular, I haven’t seen it stated whether the problem is that:

                    1. the expected result of backward searching with a regular expression is not always well-defined.

                    2. the expected result is well-defined, but the implementation — due to Boost, Scintilla, Notepad++ or some combination thereof — is not always correct.

                    Is it known which applies, and under what specific conditions?

                    C 1 Reply Last reply Oct 1, 2023, 4:28 AM Reply Quote 2
                    • G
                      guy038
                      last edited by guy038 Oct 1, 2023, 3:03 AM Oct 1, 2023, 3:00 AM

                      Hello, @reinhardhofmann, @mkupper, @alan-kilborn, @peterjones, @mark-olson, @coises and All,

                      Oh…, in my previous post, I did a mistake : I spoke about a second example (?s)i.+. But, I really did tests with the regex (?-s)i.+ !

                      When the backward regex search is allowed, EACH backward regex (?-s)i.+ finds a string, reduced by a single character

                      But, unfortunately, Alan, the regex (?-s)i.+(?=(?s).) do not give the expected results, allthough it reduces the number of steps before a CORRECT backward occurrence !


                      Thus, my general rule should be modified as :

                      When a backward regex do not work as expected, try adding the regex string (?=(?s).) at the end of the present regex. It may work correctly !

                      Best Regards,

                      guy038

                      1 Reply Last reply Reply Quote 0
                      • C
                        Coises @Coises
                        last edited by Oct 1, 2023, 4:28 AM

                        I wrote in Shift+F3 no more works that the problem might be:

                        the expected result of backward searching with a regular expression is not always well-defined.

                        Example of how this could be ambiguous:

                        Given the text:
                        xabcdefy
                        and the regular expression:
                        (a..(d..)?|.e)

                        when matching normally there is one match — abcdef. When matching backward, is there one match — abcdef — or are there two matches — de and abc?

                        What about the regular expression:
                        (a..(d.)?|.f)
                        matching backward: abcde or ef and abc?

                        1 Reply Last reply Reply Quote 3
                        14 out of 15
                        • First post
                          14/15
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors