> Hi Gurus,
>
> I could not understand the descriptions below about the usage of \@!.
> "a.\{-}p\@!" will match any
> "a", "ap", "aap", etc. that isn't followed by a "p", because the "."
> can match a "p" and "p\@!" doesn't match after that.
>
> I know why "a" matches the pattern. but I don't understand why "ap"
> could match the pattern "a.\{-}p\@!", so does "aap".
> why "appppp" also matches the pattern?
>
> from the pattern "a.\{-}p\@!", I can tell:
> if the pattern is a.{-}p, it will match ap, aaaap and
> absdfasdfasdasdfasdp since .\{-} could be 0 to more chars as few as
> possible,but followed with a p.
> if\@! is after p, does it mean p should not appear at the end? why ap
> is ok? adsfasdasdfap appp is matched the pattern "a.\{-}p\@!"?????
>
'a' matches because .\{-} could be zero characters
'ap' matches because .\{-} matches the p, and then the next character
is not a p, matching the p\@! with zero width. End-of-line is also
"not a p" so that matches as well.
The root of the problem is the use of the '.' character which also
matches the p. If you want to rule out ap, aaap, etc. then you'd want
a[^p]* or similar.
--
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