Saturday, January 2, 2010

Re: Patterns, variables and strange behavior of some thing.

jojahti wrote:
>> There's a better way to do what you're trying to do, which uses \zs
>> instead of \@<=.
> Thanks.
> Mmmm. But if i use "\zs" instead "\@<=" in next example - he not work at
> all.
> "\(\(int\|long\|short\|char\|void\|double\)[[:space:]]\+\)\@<=[^[:space:]^(^).]\+\([[:space:]]\)\@="
>
> But in litle experimental examples this work. But I with it will experiment
> with it.
>
>> Out of curiosity, what are you trying to match with [^[:space:]^(^).]?
> Word, which does not contained "( )". I finding a variables, but not
> functions, and declarations of classes.
> "int frog" - it will be found. "int frog()" - it will be not found.

Note that the first ^ within the [ ... ] complements the collection; the
others are matched literally. If I understand correctly what you're
trying to do, the collection should be defined like this: [^[:space:]().]

>
>> Now I'm confused as to what you're actually attempting to do...
> I not so understand programming, I study him likely.
> Now i simply learn to work in the editor of a code, and try to do my own
> syntax highlighting.
> In this stage - i try make variables highlighting.
>
> "(type (name_variables)some_simvols)\@<=(\2)"
>
> As it not were correctly work in the next example.(this can find only one
> simvols of the word )), but in this variant the example looks easier, and it
> is not similar to spells of severe northern mammoths.)
> string " int d ii iiii ii d"
> pattern '\(int[[:space:]]\+\([^[:space:]]\+\).*\)\zs\2'
>
> P.S. And one little question.
> This string "oooooooBBoooooooBoooo"
> And patterne '\(B\)\=\1'
> Why this patterne not work? :WALL:

It does work, but it's rather pointless because it matches everywhere.
It will match a B followed by another B, but it will also match the
empty string, since the \= makes the match with the B optional. Recall
that \= matches 0 or 1 of the preceding atom. In your example, when the
match is attempted at one of the o's, it succeeds as follows...

the B matches 0 times
\1 is empty and hence it matches also (since an empty pattern matches
everywhere)

Brett Stahlman

> This is too quirk? )

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: