Write regular expressions to match...
  1. Five-digit or "zip+4" zipcodes
  2. Positive integers that are even or divisible by 5
  3. Octal (base 8) literals less than 1024
  4. Haskell lists with only integer literals
  5. Words from /usr/share/dict/words that contain all five vowels, in aeiou order
  6. Lines whose length is a multiple of 3 or 5
  7. Lines of cal output where the 10th or 20th falls on a Saturday. Test on lectura like this, perhaps:
    $ alias rg="ruby /cs/www/classes/cs372/spring14/ruby/rgrep.rb"
    $ cal 9 2014 | rg 'YOUR-RE-HERE'
    

    Note: There's a long story about the regular expressions recognized by grep and egrep. To keep focused on regular expressions as recognized by Ruby, I recommend using something simple like rgrep.rb, which provides a direct, simple way to use Ruby regular expressions. As a think-less rule, enclose regular expressions on the command line in single-quotes.

  8. Lines of Ruby source code that...
    1. possibly have uses of "if"s that use an assignment instead of ==.
    2. are of the form VAR = VAR or VAR = VAR[EXPR]
    3. possibly deserve scrutiny wrt. the longest.rb restrictions
    4. possibly deserve scrutiny wrt. the seqwords.rb restrictions
    Assuming the rg alias above you might test like this:
    cat *.rb | rg 'YOUR-RE-HERE'
    
    Of course, rgrep.rb simply prints matching lines. You might augment it with something like show_match (slide 164) or something adapted from the example on slide 188, to name two possibilities.
  9. Lines of ls -l output that are...
    1. for directories
    2. for files that are mode 444. (Do touch x; chmod 444 x; ls -l x to make one and see it.)
    3. for files whose name contains the owner's name
  10. Retail prices less than $100. Prices might be in cents but never more than 99c. Prices might be in whole dollars.
  11. Be creative: For a point or two of extra credit on assignment 4, post a follow-up problem or two like the above. For an additional point or two, reverse it: ask a question like What does -?\d+ match?, with a regular expression that matches something that's common and recognizable, like "the integers".