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

Re: \v(str|&&) causes "E874: (NFA) Could not pop the stack !"

Expand Messages
  • kien
    ... & didn t/doesn t need to be escaped. ` v(&&|str)` works without any error. Also, this is from an existing line of code so I prefer not to have to change
    Message 1 of 7 , Jun 19, 2013
    • 0 Attachment
      On Thursday, June 20, 2013 10:07:59 AM UTC+7, Ben Fritz wrote:
      > On Wednesday, June 19, 2013 8:13:55 PM UTC-5, kien wrote:
      > > While `\v(&&|str)` (order reversed) works and doesn't cause the error.
      > >
      > > Both expressions work with the old regexp engine.
      >
      > While you shouldn't get an error message...I don't think that pattern is doing what you think unless you're just trying weird things to break the regex engine.
      >
      > With very magic on, & by itself is the same as \& with regular magic. It looks like you're trying to match a literal string of two '&' characters. For that, if using \v, you need to escape it with a backslash. See :help /\&.

      & didn't/doesn't need to be escaped. `\v(&&|str)` works without any error.

      Also, this is from an existing line of code so I prefer not to have to change it, especially when there have been issues like `\@>, \@!, etc. not supported`, or `only accepts up to \{,10}`.

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Ben Fritz
      ... What do you mean by works ? What are you trying to match? For me, in this line of text: one two three && four five six str seven eight ...the pattern
      Message 2 of 7 , Jun 19, 2013
      • 0 Attachment
        On Wednesday, June 19, 2013 10:40:49 PM UTC-5, kien wrote:
        > On Thursday, June 20, 2013 10:07:59 AM UTC+7, Ben Fritz wrote:
        > > On Wednesday, June 19, 2013 8:13:55 PM UTC-5, kien wrote:
        > > > While `\v(&&|str)` (order reversed) works and doesn't cause the error.
        > > >
        > > > Both expressions work with the old regexp engine.
        > >
        > > While you shouldn't get an error message...I don't think that pattern is doing what you think unless you're just trying weird things to break the regex engine.
        > >
        > > With very magic on, & by itself is the same as \& with regular magic. It looks like you're trying to match a literal string of two '&' characters. For that, if using \v, you need to escape it with a backslash. See :help /\&.
        >
        > & didn't/doesn't need to be escaped. `\v(&&|str)` works without any error.
        >

        What do you mean by "works"? What are you trying to match? For me, in this line of text:

        one two three && four five six str seven eight

        ...the pattern matches EVERYWHERE.

        This is because the match \v&& means "match wherever an empty string and another empty string match at the same location". This is between every single character in the line.

        I assumed you wanted to match either the text "&&" or the text "str". If I escape the & characters as \&, this is exactly what I get.

        --
        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • kien
        ... You didn t, and still doesn t need to escape & if using ` v(&&|str)` or ` v&`. It s just the ` v(str|&&)` that causes the error. That s the problem. I
        Message 3 of 7 , Jun 19, 2013
        • 0 Attachment
          On Thursday, June 20, 2013 11:06:20 AM UTC+7, Ben Fritz wrote:
          > If I escape the & characters as \&, this is exactly what I get.

          You didn't, and still doesn't need to escape & if using `\v(&&|str)` or `\v&`. It's just the `\v(str|&&)` that causes the error. That's the problem. I thought I had made this clear enough in the first email.

          --
          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Ben Fritz
          ... I understand you get an error for the str|&& pattern. I agree you should not get an error. I can duplicate the error. Aside from the error, I was trying to
          Message 4 of 7 , Jun 19, 2013
          • 0 Attachment
            On Wednesday, June 19, 2013 11:19:44 PM UTC-5, kien wrote:
            > On Thursday, June 20, 2013 11:06:20 AM UTC+7, Ben Fritz wrote:
            > > If I escape the & characters as \&, this is exactly what I get.
            >
            > You didn't, and still doesn't need to escape & if using `\v(&&|str)` or `\v&`. It's just the `\v(str|&&)` that causes the error. That's the problem. I thought I had made this clear enough in the first email.

            I understand you get an error for the str|&& pattern. I agree you should not get an error. I can duplicate the error.

            Aside from the error, I was trying to helpfully point out that \v with && in the pattern will NOT match a literal && string, which I assume is the intent of the pattern.

            If you actually want a pattern that matches everywhere, then that's up to you. But somehow I don't think this is really what you want.

            And yes, I tested. \v(&&|str) matches everywhere in any text, regardless of the regexpengine setting.

            You absolutely need to escape a & character if you use \v in a pattern, and expect to match a literal '&' character. Otherwise it acts as a "branch" as detailed at :help /\&. If you do NOT use \v in the pattern, then && will in fact match a literal "&&" string.

            --
            --
            You received this message from the "vim_dev" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_dev" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • kien
            ... You re right. I actually never realized this since I tested these expressions with `=~`. My apologies! And thanks for pointing this out and making it
            Message 5 of 7 , Jun 19, 2013
            • 0 Attachment
              > one two three && four five six str seven eight
              >
              > ...the pattern matches EVERYWHERE.

              You're right. I actually never realized this since I tested these expressions with `=~`.

              My apologies! And thanks for pointing this out and making it clear!

              So while the error shouldn't happens, it's kind of irrelevant to my situation.

              --
              --
              You received this message from the "vim_dev" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php

              ---
              You received this message because you are subscribed to the Google Groups "vim_dev" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            Your message has been successfully submitted and would be delivered to recipients shortly.