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

73136Re: VIML regex comparison problem

Expand Messages
  • ZyX
    Sep 9, 2013
    • 0 Attachment
      > I had tried calls to escape(..., '\') and that made no difference.
      > Changing the test
      >
      > if l:d !~ "^\V" . s:dir1
      >
      > makes no difference.

      It makes difference with some specific directory names. “Specific” includes dots in directory name.

      > If I substitute all back slashes for forward slashes then it works as I
      > expect. So basically I tripped and fallen into backslash hell, again.
      >
      > > b) you do not need regular expressions at all, use l:d[:len(s:dir1)-1] is#
      > > s:dir1 (use is? for windows).
      >
      > Which does work (toss up between using is# and ==# in this case) -
      > thanks :-)

      “A is# b” is like “type(A) == type(b) && A ==# b”. I just use it always for string comparison because I constantly use zero as a substitution for python None (e.g. as a default value) and “"abc" == 0” is true because if one of the “==” operands is a number another operand is also coerced to a number. Using “#” and “?” is a good habit because it is bad idea to rely on user settings.

      Note that I use is# here not because I expect number as one of the operands *here*. I use it because it is string comparison and in some *other* string comparisons I write numbers are expected.

      --
      --
      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.
    • Show all 10 messages in this topic