Loading ...
Sorry, an error occurred while loading the content.

A Change in Pattern Matching?

Expand Messages
  • Johnny Blaze
    Call me crazy, but I could have sworn ... aaaaa ... a since %( ) groups, but doesn t create submatches, whereas ( ) does.... If I change + to * it returns
    Message 1 of 3 , Mar 1, 2005
    • 0 Attachment
      Call me crazy, but I could have sworn

      :echo matchstr('aaaaa', '\(\%(a\| \)\+\)')
      aaaaa

      instead Vim 7 (as of 2/28) returns:

      :echo matchstr('aaaaa', '\(\%(a\| \)\+\)')
      a

      since \%(\) groups, but doesn't create submatches, whereas \(\)
      does.... If I change \+ to * it returns as expected, which seems to
      confirm my suspicions as * matches 0 to many (greedy), while \+
      matches 1 to many (greedy).

      Any ideas?
      --

      . o O pyromancer O o .
    • Bram Moolenaar
      ... This is very likely caused by my change to allow potentially empty matches inside the ( ). I ll look into it (after I fix my burned down PC :-( ). --
      Message 2 of 3 , Mar 1, 2005
      • 0 Attachment
        Johnny Blaze wrote:

        > Call me crazy, but I could have sworn
        >
        > :echo matchstr('aaaaa', '\(\%(a\| \)\+\)')
        > aaaaa
        >
        > instead Vim 7 (as of 2/28) returns:
        >
        > :echo matchstr('aaaaa', '\(\%(a\| \)\+\)')
        > a
        >
        > since \%(\) groups, but doesn't create submatches, whereas \(\)
        > does.... If I change \+ to * it returns as expected, which seems to
        > confirm my suspicions as * matches 0 to many (greedy), while \+
        > matches 1 to many (greedy).
        >
        > Any ideas?

        This is very likely caused by my change to allow potentially empty
        matches inside the \(\). I'll look into it (after I fix my burned down
        PC :-( ).

        --
        hundred-and-one symptoms of being an internet addict:
        269. You wonder how you can make your dustbin produce Sesame Street's
        Oscar's the Garbage Monster song when you empty it.

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
        \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html ///
      • Johnny Blaze
        ... Thank you sir. -- . o O pyromancer O o .
        Message 3 of 3 , Mar 1, 2005
        • 0 Attachment
          On Tue, 01 Mar 2005 22:56:32 +0100, Bram Moolenaar <Bram@...> wrote:
          >
          > This is very likely caused by my change to allow potentially empty
          > matches inside the \(\). I'll look into it (after I fix my burned down
          > PC :-( ).

          Thank you sir.

          --

          . o O pyromancer O o .
        Your message has been successfully submitted and would be delivered to recipients shortly.