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

Re: Feature request: Regex "not identifier" character class.

Expand Messages
  • ZyX
    ... No way for _i / _k . _ already has fixed meaning: add newline to given character class and this change will be incompatible with current behavior.
    Message 1 of 5 , Dec 12, 2012
    • 0 Attachment
      четверг, 13 декабря 2012 г., 0:49:13 UTC+4 пользователь So8res написал:
      > The \i and \k regex character classes are very useful, matching identifier and keyword characters respectively. You might think that \I and \K match non-(identifier,keyword) characters, but that is not what they do.
      >
      > As far as I can tell, there's no (easy) way in a regex to match non-identifier/non-keyword characters.
      >
      > I propose adding such character classes, potentially under the names \_i and \_k. I'm not entirely satisfied with those. Any other suggestions for names?
      >
      > (Alternatively, is there a way to do this that I couldn't find in the help?)

      No way for "\_i"/"\_k". "\_" already has fixed meaning: "add newline to given character class" and this change will be incompatible with current behavior.

      To match non-id/non-keyword character you should use negative look-ahead: "\v%(\i@!.)+" will match one or more non-id characters.

      --
      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
    • Bram Moolenaar
      ... Right, it s not easy to match the opposite of i and k. _ is reserved for items including a line break. Perhaps we can make a generic solution with -
      Message 2 of 5 , Dec 13, 2012
      • 0 Attachment
        So8res wrote:

        > The \i and \k regex character classes are very useful, matching
        > identifier and keyword characters respectively. You might think that
        > \I and \K match non-(identifier,keyword) characters, but that is not
        > what they do.
        >
        > As far as I can tell, there's no (easy) way in a regex to match
        > non-identifier/non-keyword characters.
        >
        > I propose adding such character classes, potentially under the names
        > \_i and \_k. I'm not entirely satisfied with those. Any other
        > suggestions for names?
        >
        > (Alternatively, is there a way to do this that I couldn't find in the help?)

        Right, it's not easy to match the opposite of \i and \k.

        \_ is reserved for items including a line break.

        Perhaps we can make a generic solution with \- meaning "the opposite
        of". At least instead of finding the few characters that don't have a
        meaning yet.

        --
        hundred-and-one symptoms of being an internet addict:
        153. You find yourself staring at your "inbox" waiting for new e-mail
        to arrive.

        /// 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
      • Ben Fritz
        ... What about instead of trying to find characters to pair with a , we just define new classes similar to [[:alnum:]] like [[:identifier:]] and [[:keyword:]]
        Message 3 of 5 , Dec 13, 2012
        • 0 Attachment
          On Thursday, December 13, 2012 3:28:26 PM UTC-6, Bram Moolenaar wrote:
          > So8res wrote:
          >
          >
          >
          > > The \i and \k regex character classes are very useful, matching
          >
          > > identifier and keyword characters respectively. You might think that
          >
          > > \I and \K match non-(identifier,keyword) characters, but that is not
          >
          > > what they do.
          >
          > >
          >
          > > As far as I can tell, there's no (easy) way in a regex to match
          >
          > > non-identifier/non-keyword characters.
          >
          > >
          >
          > > I propose adding such character classes, potentially under the names
          >
          > > \_i and \_k. I'm not entirely satisfied with those. Any other
          >
          > > suggestions for names?
          >
          > >
          >
          > > (Alternatively, is there a way to do this that I couldn't find in the help?)
          >
          >
          >
          > Right, it's not easy to match the opposite of \i and \k.
          >
          >
          >
          > \_ is reserved for items including a line break.
          >
          >
          >
          > Perhaps we can make a generic solution with \- meaning "the opposite
          >
          > of". At least instead of finding the few characters that don't have a
          >
          > meaning yet.
          >

          What about instead of trying to find characters to pair with a \, we just define new classes similar to [[:alnum:]] like [[:identifier:]] and [[:keyword:]] and maybe [[:fname:]]. Then non-matches would just use negation with [^...] just like other character classes.

          --
          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
        • Nate Soares
          +1 to [:identifier:] and [:keyword:]. Unfortunately, outside of i and k convention is that uppercase means negation ( s and S, w and W, etc.). We can t
          Message 4 of 5 , Dec 13, 2012
          • 0 Attachment
            +1 to [:identifier:] and [:keyword:].

            Unfortunately, outside of \i and \k convention is that uppercase means negation (\s and \S, \w and \W, etc.). We can't use that because \I and \K already exist (and \I\i* is a fairly useful pattern).

            I'm +0 on \- meaning negation. You'd then have overlap between \S and \-s but I do think it's nice to have a way to match [^[:identifier:]] without resorting to the square bracket negation.


            On Thu, Dec 13, 2012 at 1:44 PM, Ben Fritz <fritzophrenic@...> wrote:
            On Thursday, December 13, 2012 3:28:26 PM UTC-6, Bram Moolenaar wrote:
            > So8res wrote:
            >
            >
            >
            > > The \i and \k regex character classes are very useful, matching
            >
            > > identifier and keyword characters respectively. You might think that
            >
            > > \I and \K match non-(identifier,keyword) characters, but that is not
            >
            > > what they do.
            >
            > >
            >
            > > As far as I can tell, there's no (easy) way in a regex to match
            >
            > > non-identifier/non-keyword characters.
            >
            > >
            >
            > > I propose adding such character classes, potentially under the names
            >
            > > \_i and \_k. I'm not entirely satisfied with those. Any other
            >
            > > suggestions for names?
            >
            > >
            >
            > > (Alternatively, is there a way to do this that I couldn't find in the help?)
            >
            >
            >
            > Right, it's not easy to match the opposite of \i and \k.
            >
            >
            >
            > \_ is reserved for items including a line break.
            >
            >
            >
            > Perhaps we can make a generic solution with \- meaning "the opposite
            >
            > of".  At least instead of finding the few characters that don't have a
            >
            > meaning yet.
            >

            What about instead of trying to find characters to pair with a \, we just define new classes similar to [[:alnum:]] like [[:identifier:]] and [[:keyword:]] and maybe [[:fname:]]. Then non-matches would just use negation with [^...] just like other character classes.

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