Back to labs/answer key page

grep and egrep regular expressions, decreasing order of precedence (Kernighan and Pike 1984 The UNIX Programming Environment:105)

c any non-special character c matches itself
\c turn off any special meaning of character c
^ beginning of line
\ send of line
. any single character
[...] any one of the characters in ...; ranges like a-z are legal
[^...] any single character not in ...; ranges are legal
\n what the nth \(...\) matched (grep only)
r* zero ore more occurrences of r
r+ one or more occurrences of r (egrep only)
r? zero or one occurrences of r (egrep only)
r1r2 r1 followed by r2
r1|r2 r1 or r2 (egrep only)
\(r\) tagged regular expression r (grep only); can be nested
(r) regular expression r (egrep only); can be nested
No regular expression matches a newline.

Back to labs/answer key page

-----

Emily M. Bender
Last modified: Wed Mar 7 13:40:20 2001