Exercise 4 — CSC207H: Summer 2009
                 July 2009     
            Su Mo Tu We Th Fr Sa
                      1  2  3  4
             5  6  7  8  9 10 11
            12 13 14 15 16 17 18
            19 20 21 22 23 24 25
            26 27 28 29 30 31   
            
        

Due Tuesday, July 28th, 2009 at 10:00am sharp.

Create a subdirectory named e4 in your exercises directory in your repository and put the file ex4 (described below) in that subdirectory. Make sure your file name is exactly ex4, including capitalization.

What to do for this exercise

  1. Create a two-line file "ex4" that contains the regular expressions specified below.
  2. Check ex4 into your repository.

Specifications for ex4

Each line of ex4 is a separate regular expression. It should be entered as just a string, without quotation marks. Thus, the following on its own line in the file would match all ten digit base 10 numbers: \d{10}not \\d{10}. Your regular expressions will be read by a program, but they are not part of a program.

Here is what the two regular expressions must do:

  1. The regular expression in the first line of ex4 must match strings beginning with ten (base 10) digits — think of it as a student number — followed by two spaces, following by a name in the Scots-Irish style: beginning with "Mc" or "Mac", followed by an upper-case letter, followed by one or more lower-case letters, followed by a tab character. There might be more characters in the line after that, but we're not interested in them.
  2. The regular expression in the second line of ex4 must match strings containing exactly three commas. This means that the entire string, from beginning to end, must contain no more and no fewer than three commas. There may be any number of non-comma characters anywhere in the string.

Your regular expressions will be tested using the Java function Pattern.matches.

You will get one mark for each regular expression that works on every test case we use.