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 ~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 emacs 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" menu in
emacs. Remember that neither of these programs
expect you to enter the "/" delimiters when you
type the RE for which to search. Also, note that emacs normally
ignores case in 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 underlining all matches. For example, the RE
/(.*)/ matches 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.
Find all possible matches for each of the following REs:
/[Ff][^ ]*/
/line[a-z]*/
/c.*r/
/text/
/\*+/
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):
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
cs2304u@ei.cs.vt.edu.
To receive credit, you 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.
The body of your message must be a plain ASCII text file that contains the following: