or \z( pattern \) |/\z(|
*/\%#=* *two-engines* *NFA*
Vim includes two regexp engines:
1. An old, backtracking engine that supports everything.
2. A new, NFA engine that works much faster on some patterns, possibly slower
on some patterns.
*E1281*
Vim will automatically select the right engine for you. However, if you run
into a problem or want to specifically select one engine or the other, you can
prepend one of the following to the pattern:
\%#=0 Force automatic selection. Only has an effect when
'regexpengine' has been set to a non-zero value.
\%#=1 Force using the old engine.
\%#=2 Force using the NFA engine.
You can also use the 'regexpengine' option to change the default.
*E864* *E868* *E874* *E875* *E876* *E877* *E878*
If selecting the NFA engine and it runs into something that is not implemented
the pattern will not match. This is only useful when debugging Vim.
==============================================================================
3. Magic */magic*
Some characters in the pattern, such as letters, are taken literally. They
match exactly the same character in the text. When preceded with a backslash
however, these characters may get a special meaning. For example, "a" matches
the letter "a", while "\a" matches any alphabetic character.
Other characters have a special meaning without a backslash. They need to be
preceded with a backslash to match literally. For example "." matches any
character while "\." matches a dot.
If a character is taken literally or not depends on the 'magic' option and the
items in the pattern mentioned next. The 'magic' option should always be set,
but it can be switched off for Vi compatibility. We mention the effect of
'nomagic' here for completeness, but we recommend against using that.
*/\m* */\M*
Use of "\m" makes the pattern after it be interpreted as if 'magic' is set,
ignoring the actual value of the 'magic' option.
Use of "\M" makes the pattern after it be interpreted as if 'nomagic' is used.
*/\v* */\V*
Use of "\v" means that after it, all ASCII characters except '0'-'9', 'a'-'z',
'A'-'Z' and '_' have special meaning: "very magic"
Use of "\V" means that after it, only a backslash and the terminating
character (usually / or ?) have special meaning: "very nomagic"
Examples:
after: \v \m \M \V matches ~
'magic' 'nomagic'
a a a a literal 'a'
\a \a \a \a any alphabetic character
. . \. \. any character
\. \. . . literal dot
$ $ $ \$ end-of-line
* * \* \* any number of the previous atom
~ ~ \~ \~ latest substitute string
() \(\) \(\) \(\) group as an atom
| \| \| \| nothing: separates alternatives
\\ \\ \\ \\ literal backslash
\{ { { { literal curly brace
If you want to you can make a pattern immune to the 'magic' option being set
or not by putting "\m" or "\M" at the start of the pattern.
==============================================================================
4. Overview of pattern items *pattern-overview*
*E865* *E866* *E867* *E869*
Overview of multi items. */multi* *E61* *E62*
More explanation and examples below, follow the links. *E64* *E871*
multi ~
'magic' 'nomagic' matches of the preceding atom ~
|/star| * \* 0 or more as many as possible
|/\+| \+ \+ 1 or more as many as possible
|/\=| \= \= 0 or 1 as many as possible
|/\?| \? \? 0 or 1 as many as possible
|/\{| \{n,m} \{n,m} n to m as many as possible
\{n} \{n} n exactly
\{n,} \{n,} at least n as many as possible
\{,m} \{,m} 0 to m as many as possible
\{} \{} 0 or more as many as possible (same as "*")
|/\{-| \{-n,m} \{-n,m} n to m as few as possible
\{-n} \{-n} n exactly
\{-n,} \{-n,} at least n as few as possible
\{-,m} \{-,m} 0 to m as few as possible
\{-} \{-} 0 or more as few as possible
*E59*
|/\@>| \@> \@>