Community
    • Login

    Npp v8.7.8 or later hangs for `^.{0,20}` at the end of a file

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 3 Posters 129 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.
    • mkupperM
      mkupper
      last edited by

      In this forum thread @coises had posted a regexp that included {0,4000}

      I wondered if the zero was needed and so tested marking with ^.{,20} to see the first 20 characters of each line highlighted. Notepad reported Find: Can't find the text "^.{,20}" in entire file. That was a bit curious as I’m not sure what the engine was trying to match.

      I then tried ^.{1,20} and it marks the first 20 characters for all lines that are 1 to 20 or more characters long.

      Next I tried ^.{0,20} This works much like ^.{1,20} and also reports ^ zero length match on the empty lines as expected. However, when it was at the end of the file Notepad++ hangs rather than wrapping to the start of the file.

      ^.{0,20} works and wraps at the end of a file for npp v8.7.7.
      ^.{0,20} works but hangs at the end of a file for npp v8.7.8 and v8.7.9.

      Before posting a bug report I’m wondering if there is something else we could try that seems useful.

      CoisesC 3 Replies Last reply Reply Quote 1
      • CoisesC
        Coises @mkupper
        last edited by

        @mkupper
        Sounds like this:

        https://github.com/notepad-plus-plus/notepad-plus-plus/pull/16371

        which was accepted but is not yet in a release.

        1 Reply Last reply Reply Quote 1
        • CoisesC
          Coises @mkupper
          last edited by

          @mkupper said in Npp v8.7.8 or later hangs for `^.{0,20}` at the end of a file:

          Notepad reported Find: Can’t find the text “^.{,20}” in entire file. That was a bit curious as I’m not sure what the engine was trying to match.

          Per Boost documentation:

          Note that the “{” and “}” characters will treated as ordinary literals when used in a context that is not a repeat: this matches Perl 5.x behavior.

          Leading comma within curly braces is not a valid syntax, so it’s searching for the beginning of a line followed by any one character and then the literal characters {,20}.

          mpheathM 1 Reply Last reply Reply Quote 3
          • CoisesC
            Coises @mkupper
            last edited by

            @mkupper See also:
            https://community.notepad-plus-plus.org/topic/26737/notepad-release-8-7-9/2?_=1744230923582
            and following comments.

            1 Reply Last reply Reply Quote 1
            • mpheathM
              mpheath @Coises
              last edited by

              @Coises said in Npp v8.7.8 or later hangs for `^.{0,20}` at the end of a file:

              Leading comma within curly braces is not a valid syntax, so it’s searching for the beginning of a line followed by any one character and then the literal characters {,20}.

              Python’s re allows that syntax of omitting the minimum repetition. To use {,20} instead of {0,20} would be like learning a bad habit compared to Boost or other regex libraries.

              https://www.pcre.org/original/doc/html/pcrepattern.html quote:

              An opening curly bracket that appears in a position where a quantifier is not allowed, or one that does not match the syntax of a quantifier, is taken as a literal character. For example, {,6} is not a quantifier, but a literal string of four characters.

              This is stated explicitly that {,6} is a “literal string”.

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