regular-expression – ¿Cuál es el nombre del token '\%' y '\ @' en vim regex? Y que hace

Pregunta:

Mientras editaba el archivo de sintaxis, encontré algo como:

\s*\%(\%(:\@<!\/\/.*\)\=\|\%(\/\*.*\*\/\s*\)*\)$

Estoy familiarizado con cualquier otro que no sea \% y \@ allí. Ni siquiera puedo buscar en Google porque no sé cuál es su nombre. Entonces, ¿qué es y para qué sirve?

Respuesta:

Antes de buscar en Google, pruebe el documento:

Desde :h \%

\%(\)   A pattern enclosed by escaped parentheses.
    Just like \(\), but without counting it as a sub-expression.  This
    allows using more groups and it's a little bit faster.
    {not in Vi}

Y :h \@<!

\@<!    Matches with zero width if the preceding atom does NOT match just
    before what follows.  Thus this matches if there is no position in the
    current or previous line where the atom matches such that it ends just
    before what follows.

    Like "(?<!pattern)" in Perl, but Vim allows non-fixed-width patterns.
    The match with the preceding atom is made to end just before the match
    with what follows, thus an atom that ends in ".*" will work.
    Warning: This can be slow (because many positions need to be checked
    for a match).  Use a limit if you can, see below.

    Example         matches ~

    \(foo\)\@<!bar      any "bar" that's not in "foobar"

    \(\/\/.*\)\@<!in    "in" which is not after "//"

Leave a Comment

Your email address will not be published.

Scroll to Top

istanbul avukat

-

web tasarım