SSH, The Secure Shell: The Definitive Guide, 2nd Edition
by Daniel J. Barrett, Richard E. Silverman, Robert G. Byrnes
Regex Syntax: Egrep Patterns
The escape character is a backslash (\). You can use it to escape metacharacters to
use them in their plain character form.
In the following examples, literal E and F
denote any expression, whether a pattern or a character:
( Start a capturing
subexpression.
) End a capturing
subexpression.
E|FDisjunction, match either
EorF(inclusive).Eis preferred if both match.E*Act as Kleene star, match
Ezero or more times.E+Closure, match
Eone or more times.E?Option, match
Eoptionally once.
. Match any character except
for newline characters (\n, \f, \r) and
the NULL byte.
E{n}Match
Eexactlyntimes.E{n,}orE{n,0}Match
Enor more times.E{,n}orE{0,n}Match
Eat mostntimes.E{n,m}Match
Eno less thanntimes and no more thanmtimes.
[ Start a character set. See
"Character Sets for Egrep and
ZSH_FILEGLOB.”
$ Match the empty string at the
end of the input or at the end of a line.
^ Match the empty string at the
start of the input or at the beginning of a line.
Escaped Tokens for Regex Syntax Egrep
The following list describes the tokens:
\0n..nThe literal byte with octal value
n..n.\0The NULL byte.
\[1-9]..xThe literal byte with decimal value
[1-9]..x.\xn..nor\0xn..nThe literal byte with hexadecimal value
n..n.\<Match the empty string at the beginning of a word.
\>Match the empty string at the end of a word.
\bMatch the empty string at a word boundary.
\BMatch the empty string provided it is not at a word boundary.
\wMatch a word-constituent ...