CS536 Homework 1 Solution


Question 1:

 

Question 2: (one possible solution)

[letter]([letter] | [digit] | [hyphen]([letter] | [digit]))*#[digit]+

Question 3:

{SLASH}{STAR}[^(*/)]*{STAR}{SLASH}

- Incorrect

{SLASH}{STAR}(.)*{STAR}{SLASH}

- Incorrect

{SLASH}{STAR}([^*]*{STAR}+[^*/])*{STAR}+{SLASH}

- Incorrect

{SLASH}{STAR}([^*]|[^/])+{STAR}{SLASH}

- Incorrect

{SLASH}{STAR}[^*]*{STAR}+{SLASH}+

- Incorrect

{SLASH}{STAR}([^*]|({STAR}+[^*/]))*{STAR}+{SLASH}

- Correct

Question 4:

{SLASH}{SLASH}([^\n]*)\n
OR
{SLASH}{SLASH}(.)*\n