[...]
>> 'a' matches because .\{-} could be zero characters
>> 'ap' matches because .\{-} matches the p,
> I don't think .\{-} will p, since \{-} is matching as few as possible.
"\{-}" doesn't just mean "as few as possible", it means "as few as
possible to make the whole pattern succeed".
If it didn't match the "p" the whole pattern would fail (because of the
"p\@!") so it does match the "p". It's a longer match, but it is the
shortest match that makes the whole pattern succeed.
(If you wanted "as few as possible regardless" you would use "\@>",
which basically divides a pattern up so that the pieces either side
behave independently. If the pattern were "a.\{-}\@>p\@!" then ".\{-}"
would always match nothing because that's the smallest match that can
succeed when there are not other restrictions. The whole pattern then
would behave the same as "ap\@!", i.e. it would match any "a" not
followed by a "p".)
Ben.
>> The root of the problem is the use of the '.' character which also
>> matches the p.
> why . matches p? I don't understand since . is followed by \{-}, which
> mean as few as possible,
> so I think a.\{-} will only a, aa, aa, aaa, etc.
--
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
No comments:
Post a Comment