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

RE: bug in pattern matching ???

Expand Messages
  • Bram Moolenaar
    ... Since I didn t change anything in this area for quite a while, I can t imagine that this ever worked. ... By searching for a , entered as CTRL-V
    Message 1 of 7 , May 31, 2001
      Ron Aaron wrote:

      > >> let files=glob('*.c')
      > >> echo matchstr(files, ".*\n\\{0,1}")
      > >>
      > >> --> used to print out just the first file, now it prints all
      > >>the files
      > >When did it used to match only the first file? ".*" matches
      > >the whole thing, and you match zero times "\n".
      > All I know is that the code did work as I intended prior to 6.0ah . The
      > intention was to match anything up to a newline; but I see it was incorrect
      > code. However, using 'stridx' in this case is probably much faster than
      > using match()...

      Since I didn't change anything in this area for quite a while, I can't imagine
      that this ever worked.

      > >In a string "\n" is handled like a LF character, not a real line break.
      > >That's different from how it is in the text, for
      > >implementation reasons (can't
      > >have a NUL in a string).
      > How can we e.g. search for a NUL in a binary file?

      By searching for a <NL>, entered as CTRL-V CTRL-J. That's different from
      "\n", which matches a line break. I know, this isn't obvious. It's difficult
      to make it work in all situations and still keep it simple.

      You have the right to remain silent. Anything you say will be
      misquoted, then used against you.

      /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
      ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim )))
      \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
    Your message has been successfully submitted and would be delivered to recipients shortly.