CSCI 431 Homework 4

time due submission file
9:00 AM Wednesday 20 September, 2006 csci/431/HW2/

The assignment

Download the starter Perl script and look it over. It's a script that reads lines from standard input and matches them against regular expressions, written in Perl's fine syntax.

Presently, the program reads a line and will print an 'A' if the line contains the string 'CSCI' and will print a 'B' if the line, in entirety, mathes the regular expression C*S*C*I*.

Your task is to add more regular expression matches. You may not use other control structures, such as conditional statements or additional variables, to solve this problem. It has to be a pure regular expression match.

The table below explains what your program should be looking for and which letter it prints when if finds what it is looking for.

A The string CSCI occurs anywhere within the input line.
B The regular expression C*S*C*I* matches the line.
C Within the line are 11 characters that could be a Social Security number (three digits, hyphen, two digits, hyphen, four digits).
D The line contains both of the strings 'UNCA' and 'WCU'.
E The line contains no periods.
F The line contains exactly three periods.
G The line consists of a legal Java floating point number with no surrounding blanks.
H The line contains exactly five words.
I Every 'A' that appears within the line is followed by a 'B'.
J Every 'A' that appears within the line is preceded by a 'B'.

Perl RE's

Googling for "perl regular expressions" will give you more than enough information to complete this assignment.