The metacharacters available in vi's search and substitution regular expressions are described in Section 6.3.1 in Chapter 6. Each of the clones provides some form of extended regular expressions, either as an option or always available. Typically these are the same (or almost the same) as what's provided by egrep. Unfortunately, each one's extended flavor is slightly different from the others'.
To give you a feel for what extended regular expressions can do, we present them in the context of nvi. Each clone's chapter then describes that editor's extended syntax, without repeating the examples.
Besides the standard metacharacters described in Chapter 6, and the POSIX bracket expressions mentioned in Section 6.3.2 in the same chapter, the following metacharacters are available:
When extended is set, text grouped with parentheses acts like text grouped in \(...\) in regular vi; the actual text matched can be retrieved in the replacement part of a substitute command with \1, \2, etc. In this case, \( represents a literal left parenthesis.
[42]The *, +, and ? operators can be reduced to {0,}, {1,} and {0,1} respectively, but they are much more convenient to use.
When extended is not set, nvi provides the same functionality with \{ and \}.
Copyright © 2003 O'Reilly & Associates. All rights reserved.