Skip to Content
Learning the vi and Vim Editors, 7th Edition
book

Learning the vi and Vim Editors, 7th Edition

by Arnold Robbins, Elbert Hannah, Linda Lamb
July 2008
Beginner
492 pages
16h
English
O'Reilly Media, Inc.
Content preview from Learning the vi and Vim Editors, 7th Edition

Extended Regular Expressions

We introduced extended regular expressions earlier in the section Extended Regular Expressions. Here, we just summarize the metacharacters that nvi provides. nvi also supports the POSIX bracket expressions, [[:alnum:]], and so on.

You use :set extended to enable extended regular expression matching:

|

Indicates alternation. The left and right sides need not be just single characters.

(...)

Used for grouping, to allow the application of additional regular expression operators.

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.

+

Matches one or more of the preceding regular expressions. This is either a single character or a group of characters enclosed in parentheses.

?

Matches zero or one occurrence of the preceding regular expression.

{...}

Defines an interval expression. Interval expressions describe counted numbers of repetitions. In the following descriptions, n and m represent integer constants:

{ n }

Matches exactly n repetitions of the previous regular expression.

{ n ,}

Matches n or more repetitions of the previous regular expression.

{ n , m }

Matches n to m repetitions.

When extended is not set, nvi provides the same functionality with \{ and \}.

As might be expected, when extended is set, you should precede metacharacters with a backslash in ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning the vi and Vim Editors, 8th Edition

Learning the vi and Vim Editors, 8th Edition

Arnold Robbins, Elbert Hannah
Vim Masterclass

Vim Masterclass

Jason Cannon
Mastering Vim

Mastering Vim

Ruslan Osipov

Publisher Resources

ISBN: 9780596529833Errata Page