Consider the following text, taken from the manual page for a
command called "flip" (if you would like to use
flip, you can find it compiled for FreeBSD along with it's
man page in the directory /home/faculty/sedwards/bin on
the lab machines):
If we refer to these lines by number (1 through 4), then which line(s), if any, match each of the following (Flip is a file interchange program that converts text file formats between **IX and MS-DOS. It converts lines ending with carriage-return (CR) and linefeed (LF) to lines ending with just linefeed, or vice versa.
grep) REs?
/feed/
/file$/
/^[Ff]/
/.$/
/ */
/lines*/
/lines\{0,\}/
/[Cc].*[Ff]/
/([Cc].*[D-G])/
/[Ii][at][a-z]*/
(" and ")" characters used alone match
themselves, while "\(" and "\)" are
used for grouping (these are the rules that grep and
ex/vi use,
while egrep uses the opposite conventions). All of
these REs are also case-sensitive.
If you are unsure about a question, feel free to try out a few
experiments with grep or with the "search" command
/ in vi. Remember that neither of these programs
expect you to enter the "/" delimiters when you type the
RE for which to search, and that both use case sensitive searches by
default.
For the next set of (egrep) REs, identify
all substrings
that match each RE (without crossing lines, of course) in the
four lines listed in Section 1. You can do
this by listing all the matched strings. Remember that REs match the
longest possible string.
For example, the egrep RE
/\(.*\)/ matches the following string(s):
Find all possible matches for each of the following ((CR) and linefeed (LF)
egrep) REs:
/F[^ ]*/
/line(s|[^s ]+)/
/c.*s/
/[a-z]*[e.]$/
/\*+/
Now it is your turn to write some REs to match specific text
fragments. For each of the following questions, write an RE that
matches the specified text (including but not limited to all of the
underlined phrases in each example) and no other text in
the given line, assuming that
your RE is intended to be used with grep.
hello, there. or is "hi" or "howdy" more to your liking? ----- -- -----
The quick brown fox jumps over the lazy dog. --- ---
How many sentences are here? There are two. No, three!
----- ---- ------
The number 045-35-2344 is a random SSN.
-----------
This sentence does not have many long words.
-------- -----
reusable software is software that was designed to be reused. -------- ------
Does this sentence end in a period? This one does.
--------------
Politicians can act artificial, but do they have intelligence?
-----------------------------------------
computer science is the study of computing, and how computers work. -------- --------- ---------
This is a short sentence.
---------
----------
----------------
Your submission must follow exactly the format described below, with no extra lines, omitted questions, or extraneous comments. For questions 1 through 10, give the problem number, a period, a space, and then the line numbers in order of the RE matches, separated by commas. For instance
1. 1,3,4 2. 2,3 3. 4. 2 etc.Give one problem per line, with no intervening extraneous lines. If there are no matches, terminate the line after the space following the period.
For questions 11 through 15, enter the problem number followed by a
period on a line with nothing else. Then list the matched strings one
per line, with no leading or trailing blanks, in the order they occur,
left to right, top line to bottom line. Follow all the lines containing
matched strings with exactly one blank line. For instance, the RE
/f.*m/ would be answered with
11. file interchange program form 12. etc.
For questions 16 through 25, enter the problem number followed by a
period, a space, a slash, the grep RE, and a slash
terminating the line. For instance,
16. /h[eio][a-z]*/ 17. /t[a-z]*/ etc.
You are to hand in your assignment by using the Automated Acceptor application. To receive credit, your assignment must be submitted before the time and date listed above. It is your responsibility to successfully submit your assignment via the Automated Acceptor. A maximum of three submissions is allowed per student. Brief instructions are given below on how to use the Acceptor, but it will be helpful to visit the Automated Acceptor's web page.
After connecting to the Internet, run the acceptor program with the command:
Acceptor_UI
A dialog box will then appear. Fill in your original PID, e-mail password, and Student ID. Click inside the Course Index field and select the lab section you are enrolled in. Type in HW3 for the Project Number. Enter the full path of the file to be submitted, or click on Browse to find it. After all the information is typed in, click on Submit. If your submission was successful, a window will appear stating "Your file has been submitted. A confirmation will be sent to you via e-mail." If your submission did not succeed, then a dialog box will appear describing the problem. Correct the information and resubmit. If the submission was successful, click the Quit button. After a few minutes (or sometimes hours!), you should receive an e-mail message verifying the file was received.
Also, remember that no late assignments are accepted.