On Fri, Aug 19, 2011 at 4:40 AM, Ben Fritz <fritzophrenic@gmail.com> wrote:
>
>
> On Aug 18, 11:02 am, baumann Pan <baumann....@gmail.com> wrote:
>> 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,
I don't think .\{-} will p, since \{-} is matching as few as possible.
>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.
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.
> 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
>
--
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