136213Re: trouble with pattern, character collections
- Feb 18, 2013Hi Marc!
On Mo, 18 Feb 2013, Marc Weber wrote:
> I don't think that additional threads are going to help
> There is an issue, and we should find a way to fix (IMHO).
> Let me summarize again - and tell me if you feel differently.
> Test cases:
>  echo len(matchstr("\n",'\zs[^\n]\ze'))
>  echo len(matchstr("\n","\\zs[^\n]\\ze"))
> I expect both do the same, the difference is that the second as chr(10) in [^],
> while the first has \n (which should be translated to chr(10).
> However I obsorve that  returns 0 as expected , but  does return
> 1, thus it matches \n even though I told Vim that I do not want to match
> it. People told me this was because '.' is equal to [^\n].
No, it is because "\n" is evaluated to a true line feed, so "[^\n]"
matches anything but ASCII NUL and ASCII 10, while '[^\n]' matches
anything but ASCII NUL (which is used internally by Vim to distinguish
lines from each other (e.g. a line seperator), so that a . matches
anyhing in the buffer but the line seperator)
> If so which is the best way to fix this - and which should be the way to
> express [^\n] meaning do not match \n rather than behave like '.' then ?
[^\n] should always behave like '.'
Mit freundlichen Grüßen
Letzte Worte eines Machos:
"Hallo Süße, wie wär's mit uns beiden?"
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
For more options, visit https://groups.google.com/groups/opt_out.
- << Previous post in topic Next post in topic >>