1.
Which
of these is not a situation in which you could use regular expressions?
a.
filtering
of email coming from a particular internet domain name
b.
calculation
of student grades based on percentages
c.
extraction
of all transactions in a database with a customer number of 1000 or less
d.
specification
of the format of a string representing a zip code
answer: b
2.
What
would be the output of the command: egrep ^[^A-Za-z].*! file?
a.
all
lines in file beginning with a non-alphabetic character and containing an
exclamation point elsewhere on the line
b.
the
number of lines in file beginning with a
non-alphabetic character and containing an exclamation point elsewhere on the
line
c.
all
lines in file beginning with an
alphabetic character and containing a period, an asterisk, and an exclamation
point
d.
the
number of lines in file not containing any
alphabetic characters before the first exclamation point
answer: a
3.
Which
string(s) would be matched by the regular expression: stu(dent)?
[0-9]+?
II. student
III. stu 195819588491
IV. studentdent 5
a.
I only
b.
II and III
c.
I and III
d.
I, II, III, and IV
answer: c
4.
Which
regular expression (egrep style) means all lines beginning with a number?
a. [^0-9]
b. ^[#]
c. ^[0-9]
d. [0-9].*$
answer: c
5.
Which
regular expression (egrep style) means all lines containing an alphabetic word
ending with .txt followed by a space or the end of the line?
a. *.txt
b. *.txt(
|$)
c. [a-zA-Z]*\.txt(
|$)
d. [a-zA-Z]?\.txt\n
answer: c