Regular Expressions

Syntax

The code for handling regular expressions is derived from Henry Spencer's
regexp package.  However, I have modified the syntax to resemble that of
the real vi.

ELVIS' regexp package treats the following one- or two-character strings
(called meta-characters) in special ways:

	\( \)	Used to control grouping
	^	Matches the beginning of a line
	$	Matches the end of a line
	\<	Matches the beginning of a word
	\>	Matches the end of a word
	.	Matches any single character
	[ ]	Matches any single character inside the brackets
	*	The preceding may be repeated 0 or more times
	+	The preceding may be repeated 1 or more times
	?	The preceding is optional
	\|	Separates two alternatives

Anything else is treated as a normal character which must match exactly.
The special strings may all be preceded by a backslash to force them to
be treated normally.

For example, "\(for\|back\)ward" will find "forward" or "backward", and
"\<text\>" will find "text" but not "context".


Options

ELVIS has two options which affect the way regular expressions are used.
These options may be examined or set via the :set command.

The first option is called "[no]magic".  This is a boolean option, and it is
"magic" (TRUE) by default.  While in magic mode, all of the meta-characters
behave as described above.  In nomagic mode, only ^ and $ retain their
special meaning.

The second option is called "[no]ignorecase".  This is a boolean option, and
it is "noignorecase" (FALSE) by default.  While in ignorecase mode, the
searching mechanism will not distinguish between an uppercase letter and its
lowercase form.  In noignorecase mode, uppercase and lowercase are treated
as being different.


Substitutions

The :s command has at least two arguments: a regular expression, and a
substitution string.  The text that matched the regular expression is
replaced by text which is derived from the substitution string.

Most characters in the substitution string are copied into the text literally
but a few have special meaning:

	&	Causes a copy of the original text to be inserted
	\1	Inserts a copy of that portion of the original text which
		  matched the first set of \( \) parentheses.
	\2 - \9	Does the same for the second (etc.) pair of \( \).

These may be preceded by a backslash to force them to be treated normally.
