| COS 126: Fall 1996 Exercise Set 10 |
Answers |
These exercises are intended help review the material on finite state automata. Do not turn in solutions.
egrep pattern that matches all lines that contain no
a's.egrep pattern that matches all lines that do not
contain two consecutive a's.egrep pattern that matches all lines that do not
contain three consecutive a's.egrep command that prints lines that contain no
periods.egrep pattern that matches all lines containing
dollar amounts. (Examples: $12.34 or $500.00 or $1000)./usr/dict/words that contains a
double vowel (aa, ee, ii, oo, or uu).A's.

0 1 Final? 0 3 1 1 3 2 2 2 2 3 3 1 Yes
As always, try to solve the problems before looking at the suggested solutions.
egrep -v
a-v option: egrep '^[^a]*$'[^a]* matches all strings with no a's. The ^
at the beginning and the $ at the end specify that the entire line
must be such a string. Without these, [^a]* matches every
line, because it matches strings of length 0.egrep '^a$ | ^(a?[^a]+)*$'a's, separated by single a's.
The ? (0 or 1 a's) generalizes the pattern, in the
sense that there are more ways to match it, but it is included only to avoid
specifying that the line must begin with an
a.egrep '^aa?$ | ^(a?a?[^a]+)*$'egrep -v '\.'egrep '\$([0-9])+(\.[0-9][0-9])?'% egrep 'aa|ee|ii|oo|uu' < /usr/dict/words | egrep '...............' % egrep 'aa|ee|ii|oo|uu' < /usr/dict/words | egrep '..............' committeewoman committeewomen

0
0
1
1
1.
0
1
1
3
3.
Ends in two 0s.
Try it!(0 + 10)(0* + (10)*)*