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

Regexp 'very (no) magic' flags do erratic behavior

Expand Messages
  • Ozaki Kiichi
    Hi. In regexp operation, v and V, in contrast with c, C, m and M, disable the preceding $ (end-of-line) atom. This seems to be inconsequence.
    Message 1 of 5 , Jul 2 11:57 AM
      Hi.

      In regexp operation,
      \v and \V, in contrast with \c, \C, \m and \M, disable the preceding '$' (end-of-line) atom.
      This seems to be inconsequence.


      " matching end-of-line
      echo 'hoge' =~# 'hoge$\m' | " Expect 1, Result 1
      echo 'hoge' =~# 'hoge$\M' | " Expect 1, Result 1
      echo 'hoge' =~# 'hoge$\v' | " Expect 1, Result 0 <- ?
      echo 'hoge' =~# 'hoge$\V' | " Expect 1, Result 0 <- ?

      " matching start-of-line
      echo 'hoge' =~# '\v^hoge' | " Expect 1, Result 1
      echo 'hoge' =~# '\V\^hoge' | " Expect 1, Result 1
      echo 'hoge' =~# '\m^hoge' | " Expect 1, Result 1
      echo 'hoge' =~# '\M^hoge' | " Expect 1, Result 1

      " with parentheses
      " end-of-line
      echo 'hoge' =~# '\(hoge$\)' | " Expect 1, Result 1
      echo 'hoge' =~# '\(hoge$\m\)' | " Expect 1, Result 1
      echo 'hoge' =~# '\(hoge$\M\)' | " Expect 1, Result 1
      echo 'hoge' =~# '\(hoge$\c\)' | " Expect 1, Result 1
      echo 'hoge' =~# '\(hoge$\C\)' | " Expect 1, Result 1
      echo 'hoge' =~# '\(hoge$\v)' | " Expect 1, Result 0 <- ?
      echo 'hoge' =~# '\(hoge$\V\)' | " Expect 1, Result 0 <-?

      " start-of-line
      echo 'hoge' =~# '\(^hoge\)' | " Expect 1, Result 1
      echo 'hoge' =~# '\(\v^hoge)' | " Expect 1, Result 1
      echo 'hoge' =~# '\(\V\^hoge\)' | " Expect 1, Result 1
      echo 'hoge' =~# '\(\c^hoge\)' | " Expect 1, Result 1
      echo 'hoge' =~# '\(\C^hoge\)' | " Expect 1, Result 1
      echo 'hoge' =~# '\(\m^hoge\)' | " Expect 1, Result 1
      echo 'hoge' =~# '\(\M^hoge\)' | " Expect 1, Result 1


      https://gist.githubusercontent.com/ichizok/ff37b16576321b287b0d/raw/d12eced50f1cdc2b7dcf7648814fd095d931d0a1/regexp-magic-all-after-eol.patch

      This patch checks the existence of \v and \V after '$', and sets 'magic_all' temporarily.

      Thanks.
      - Ozaki Kiichi

      --
      --
      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/d/optout.
    • Bram Moolenaar
      ... Thanks, I ll add it in the todo list. -- FATHER: We are here today to witness the union of two young people in the joyful bond of the holy wedlock.
      Message 2 of 5 , Jul 2 1:47 PM
        Ozaki Kiichi wrote:

        > In regexp operation,
        > \v and \V, in contrast with \c, \C, \m and \M, disable the preceding '$' (end-of-line) atom.
        > This seems to be inconsequence.
        >
        >
        > " matching end-of-line
        > echo 'hoge' =~# 'hoge$\m' | " Expect 1, Result 1
        > echo 'hoge' =~# 'hoge$\M' | " Expect 1, Result 1
        > echo 'hoge' =~# 'hoge$\v' | " Expect 1, Result 0 <- ?
        > echo 'hoge' =~# 'hoge$\V' | " Expect 1, Result 0 <- ?
        >
        > " matching start-of-line
        > echo 'hoge' =~# '\v^hoge' | " Expect 1, Result 1
        > echo 'hoge' =~# '\V\^hoge' | " Expect 1, Result 1
        > echo 'hoge' =~# '\m^hoge' | " Expect 1, Result 1
        > echo 'hoge' =~# '\M^hoge' | " Expect 1, Result 1
        >
        > " with parentheses
        > " end-of-line
        > echo 'hoge' =~# '\(hoge$\)' | " Expect 1, Result 1
        > echo 'hoge' =~# '\(hoge$\m\)' | " Expect 1, Result 1
        > echo 'hoge' =~# '\(hoge$\M\)' | " Expect 1, Result 1
        > echo 'hoge' =~# '\(hoge$\c\)' | " Expect 1, Result 1
        > echo 'hoge' =~# '\(hoge$\C\)' | " Expect 1, Result 1
        > echo 'hoge' =~# '\(hoge$\v)' | " Expect 1, Result 0 <- ?
        > echo 'hoge' =~# '\(hoge$\V\)' | " Expect 1, Result 0 <-?
        >
        > " start-of-line
        > echo 'hoge' =~# '\(^hoge\)' | " Expect 1, Result 1
        > echo 'hoge' =~# '\(\v^hoge)' | " Expect 1, Result 1
        > echo 'hoge' =~# '\(\V\^hoge\)' | " Expect 1, Result 1
        > echo 'hoge' =~# '\(\c^hoge\)' | " Expect 1, Result 1
        > echo 'hoge' =~# '\(\C^hoge\)' | " Expect 1, Result 1
        > echo 'hoge' =~# '\(\m^hoge\)' | " Expect 1, Result 1
        > echo 'hoge' =~# '\(\M^hoge\)' | " Expect 1, Result 1
        >
        >
        > https://gist.githubusercontent.com/ichizok/ff37b16576321b287b0d/raw/d12eced50f1cdc2b7dcf7648814fd095d931d0a1/regexp-magic-all-after-eol.patch
        >
        > This patch checks the existence of \v and \V after '$', and sets
        > 'magic_all' temporarily.

        Thanks, I'll add it in the todo list.

        --
        FATHER: We are here today to witness the union of two young people in the
        joyful bond of the holy wedlock. Unfortunately, one of them, my son
        Herbert, has just fallen to his death.
        [Murmurs from CROWD; the BRIDE smiles with relief, coughs.]
        "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ an exciting new programming language -- http://www.Zimbu.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

        --
        --
        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/d/optout.
      • Ben Fritz
        ... Shouldn t you need to escape the $ with a when using V? -- -- You received this message from the vim_dev maillist. Do not top-post! Type your reply
        Message 3 of 5 , Jul 2 7:59 PM
          On Wednesday, July 2, 2014 1:57:09 PM UTC-5, Ozaki Kiichi wrote:
          > Hi.
          >
          > In regexp operation,
          > \v and \V, in contrast with \c, \C, \m and \M, disable the preceding '$' (end-of-line) atom.
          > This seems to be inconsequence.
          >
          >
          > " matching end-of-line
          > echo 'hoge' =~# 'hoge$\m' | " Expect 1, Result 1
          > echo 'hoge' =~# 'hoge$\M' | " Expect 1, Result 1
          > echo 'hoge' =~# 'hoge$\v' | " Expect 1, Result 0 <- ?
          > echo 'hoge' =~# 'hoge$\V' | " Expect 1, Result 0 <- ?
          >

          Shouldn't you need to escape the $ with a \ when using \V?

          --
          --
          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/d/optout.
        • Павлов Николай Алекса
          ... Hash: SHA512 ... V only *starts* the region. It does not affect the whole pattern. ... Version: APG v1.1.1
          Message 4 of 5 , Jul 2 9:49 PM
            -----BEGIN PGP SIGNED MESSAGE-----
            Hash: SHA512



            On July 3, 2014 6:59:52 AM GMT+03:00, Ben Fritz <fritzophrenic@...> wrote:
            >On Wednesday, July 2, 2014 1:57:09 PM UTC-5, Ozaki Kiichi wrote:
            >> Hi.
            >>
            >> In regexp operation,
            >> \v and \V, in contrast with \c, \C, \m and \M, disable the preceding
            >'$' (end-of-line) atom.
            >> This seems to be inconsequence.
            >>
            >>
            >> " matching end-of-line
            >> echo 'hoge' =~# 'hoge$\m' | " Expect 1, Result 1
            >> echo 'hoge' =~# 'hoge$\M' | " Expect 1, Result 1
            >> echo 'hoge' =~# 'hoge$\v' | " Expect 1, Result 0 <- ?
            >> echo 'hoge' =~# 'hoge$\V' | " Expect 1, Result 0 <- ?
            >>
            >
            >Shouldn't you need to escape the $ with a \ when using \V?

            \V only *starts* the region. It does not affect the whole pattern.
            -----BEGIN PGP SIGNATURE-----
            Version: APG v1.1.1

            iQI1BAEBCgAfBQJTtODWGBxaeVggPHp5eC52aW1AZ21haWwuY29tPgAKCRCf3UKj
            HhHSvoe0EACj7eDSj+L2z+fwjssHRsapopQL5YZmhUqrY9Rym+RHEzrMsF07WmyA
            Zzl4zO7fBm1XCuIe1enA2pRI4Udy6Sq0XurfhOpHcqiePfwBcJqYG3QZqPWrX4nG
            A/hZefHGAN63LCH37RJubpzEkrJ6x4CIpEbNVsSvgmylTr99NV6IKcLwAX/1hM1R
            uGurE8R6BSSgps0g8TqdHMwwRw/dOP4NvOEu3OO5s33iTRNLv81JXm77gP5qe9Dl
            17lkeCtHTCYrmJ95ULGnKapJ7FFx2OXW5U3VCSboKUXn9eBaw9DKbUOi6Atzvsnt
            hThHxJsBUu4fiDrnWnR09O9Aqh87Zfu1gPQqCeCfdNC1OUZNWQMVf2LKLj7Nt2IW
            sb9iSyPWBszQatz6MKDzT/iAfJhBWAolEAHHA26SjYuPbe4ErJzt48lApo2az6Li
            b8T+PSloHU/Z5CY+IlrPzoNUKFmBP7SYOKcLi3Hu1NCYLV09sHdfnRPf7So96sy8
            AzshC84gXfFuGfk0mHW4Xoy+XsBte9mFTxPjlpBz5tFTqtnqIwG2q3WyD1cXlhKK
            7rVy0vQyw+hwn+QPExpwDJeD81E3C7kJpD2lK0/gBr/VY1y2qGq8J5dJPoJgAtkc
            iQGkOpAmxnV8DAlhHr2KZy6gr9zv8wMfaa/PQWAzpK4mUYwHKYCNJQ==
            =fQA/
            -----END PGP SIGNATURE-----

            --
            --
            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/d/optout.
          • Ben Fritz
            ... Ah, you re right. I was expecting it to act like c and C: */ c* */ C* When c appears anywhere in the pattern, the whole pattern is handled like
            Message 5 of 5 , Jul 2 10:07 PM
              On Wednesday, July 2, 2014 11:49:38 PM UTC-5, ZyX wrote:
              > >Shouldn't you need to escape the $ with a \ when using \V?
              >
              > \V only *starts* the region. It does not affect the whole pattern.
              >

              Ah, you're right. I was expecting it to act like \c and \C:

              */\c* */\C*
              When "\c" appears anywhere in the pattern, the whole pattern is handled like
              'ignorecase' is on. The actual value of 'ignorecase' and 'smartcase' is
              ignored. "\C" does the opposite: Force matching case for the whole pattern.
              {only Vim supports \c and \C}

              --
              --
              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/d/optout.
            Your message has been successfully submitted and would be delivered to recipients shortly.