• Login
Community
  • Login

Regex for end-of-file anchor

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
11 Posts 5 Posters 4.6k 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.
  • M
    M Andre Z Eckenrode
    last edited by Apr 15, 2021, 10:04 PM

    Not sure if this is a bug in the regex engine, or an inaccuracy of the online user manual, or just me misunderstanding something as usual…

    The manual states that \z or \` matches the end of the matching string, which I believe also means they can match the end of the file. \z works perfectly for me for that purpose, but \` seems to not match anything for me. Comments/corrections/criticisms? (I don’t have to, nor have any burning desire to, use \` , but just pointing this seeming discrepancy out, since it’s in the manual.)

    1 Reply Last reply Reply Quote 2
    • E
      Ekopalypse
      last edited by Apr 16, 2021, 9:11 AM

      There is indeed an issue, \' matches the end buffer and the other the start of buffer

      14a93da9-d909-4601-a063-084b6710bd54-image.png

      0fb69a35-aff1-426b-a314-bc9ea4db462e-image.png

      1 Reply Last reply Reply Quote 2
      • E
        Ekopalypse
        last edited by Ekopalypse Apr 16, 2021, 9:57 AM Apr 16, 2021, 9:57 AM

        @PeterJones - issue and pr opened.
        @M-Andre-Z-Eckenrode - thank you for reporting the issue.

        1 Reply Last reply Reply Quote 1
        • G
          guy038
          last edited by guy038 Apr 16, 2021, 10:43 AM Apr 16, 2021, 10:11 AM

          Hello, @m-andre-z-eckenrode, @ekopalypse, @peterjones and All ,

          The manual states :

          • \A or \' => The start of the matching string.

          • \z or \` => The end of the matching string.

          • \Z Matches like \z with an optional sequence of newlines before it. This is equivalent to (?=\v*\z), which departs from the traditional Perl meaning for this escape.

          Well, there is some typos here !

          Indeed, the correct text should be :

          • \A or \` or (?-m)^ => The start of the matching string.

          • \z or \' or (?-m)$ => The end of the matching string.

          • \Z Matches like \z with an optional sequence of vertical blank characters before it. This is equivalent to the assertion
            (?=[\n\f\r\x85\x{2028}\x{2029}]*\z), which departs from the traditional Perl meaning for this escape.

          So, @ekopalypse, there is absolutely no regex issue at all !!


          Notes :

          • For a correct behavior of the \A assertion, whatever its syntax, you must use, at least, Notepad++ v7.9.1

          • The \Z assertion is not stricly equivalent to (?=\v*\z) as the \v character class is identical to the [\n\x0B\f\r\x85\x{2028}\x{2029}] character class

          Best Regards,

          guy038

          E 1 Reply Last reply Apr 16, 2021, 10:13 AM Reply Quote 1
          • E
            Ekopalypse @guy038
            last edited by Apr 16, 2021, 10:13 AM

            @guy038

            ?? - but you yourself state that the documentation is wrong ??
            What am I missing??

            1 Reply Last reply Reply Quote 0
            • G
              guy038
              last edited by guy038 Apr 16, 2021, 10:40 AM Apr 16, 2021, 10:22 AM

              Hi, @m-andre-z-eckenrode, @ekopalypse, @peterjones and All,

              Sorry, @ekopalypse. I misspoke :

              Of course, an issue should be created to modify this part of the N++ official documentation !

              But, from a functional and regex point of view, the assertions \` , \' work properly and are identical, respectively, to the \A and \z assertions !

              BR

              guy038

              E 1 Reply Last reply Apr 16, 2021, 10:23 AM Reply Quote 2
              • E
                Ekopalypse @guy038
                last edited by Apr 16, 2021, 10:23 AM

                @guy038 - ok and I’ve created the issue and the pull request already. Just needs to be merged.

                P 1 Reply Last reply Apr 16, 2021, 2:35 PM Reply Quote 1
                • A
                  Alan Kilborn
                  last edited by Apr 16, 2021, 12:49 PM

                  @guy038 said in Regex for end-of-file anchor:

                  The manual states :

                  \A or ’ => The start of the matching string.

                  \z or ` => The end of the matching string.

                  If the manual is being improved, how about really improving it?

                  “The start of the matching string” and “The end of the matching string” are not very good phrases for the Notepad++ user/manual.

                  I guess they work fine in the context of a programmer calling the Boost C++ function (where these phrases originated from, I think).

                  But why aren’t they referred to in the Notepad++ user manual as relating to start-of-file and end-of-file, respectively?

                  P 1 Reply Last reply Apr 16, 2021, 1:05 PM Reply Quote 4
                  • P
                    PeterJones @Alan Kilborn
                    last edited by Apr 16, 2021, 1:05 PM

                    @Alan-Kilborn said in Regex for end-of-file anchor:

                    But why aren’t they referred to in the Notepad++ user manual as relating to start-of-file and end-of-file, respectively?

                    Makes sense to me. @Ekopalypse , when you get a chance, could you update your PR?

                    1 Reply Last reply Reply Quote 2
                    • P
                      PeterJones @Ekopalypse
                      last edited by Apr 16, 2021, 2:35 PM

                      @Ekopalypse ,

                      Thanks for PR#197 . It has been merged, and will be in the next release.

                      @M-Andre-Z-Eckenrode ,

                      For now, you can see the updated docs in searching.md . The fixes will be in the live document the next time there’s a website release (probably after NPP v7.9.6 is released).

                      M 1 Reply Last reply Apr 17, 2021, 5:08 PM Reply Quote 3
                      • M
                        M Andre Z Eckenrode @PeterJones
                        last edited by Apr 17, 2021, 5:08 PM

                        @PeterJones and everyone else —

                        Looks good, thanks!

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