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 REs?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.
/file/
/^f/
/^[Ff]/
/./
/ */
/line\(s\)?/
/convert|change/
/[Cc].*[Rr]/
/text.*file/
/[a-z][a-z]*ing/
(" and ")" characters used alone match
themselves, while "\(" and "\)" are
used for grouping (these are the rules that ex/vi uses,
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 egrep 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 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 RE
/(.*)/ matches the following string(s):
Find all possible matches for each of the following ((CR) and linefeed (LF)
egrep) REs:
/[Ff][^ ]*/
/line[a-z]*/
/c.*r/
/[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.
---------
----------
----------------
You are to hand in your assignment by sending an email message to the address cs1206@ei.cs.vt.edu. To receive credit, your mail message must be received by this account by the time and date listed above. It is your responsibility to successfully submit your assignment via email (remember that you will receive an auto-reply by the system when your message has been received successfully). Also, send yourself a copy for future reference. The messsage must be a plain ASCII text file, with no attachments, and in exactly the format defined below. Do not insert any extra notes or explanations.
The body of your message must be a plain ASCII text file that contains the following:
4. 1,3,4). Use one line per problem.
16. h[eio]*
).