CS 257: Software Design

Regular expressions lab

A few resources

Also

Getting started

  1. Get a clone of https://bitbucket.org/jeffondich/cs257_2016 if you don't have it already, or "git pull" if you do.
  2. Open the RegularExpression project in IntelliJ, and try out my Example X's in main().
  3. Comment out the Example X's code, and uncomment the command-line interface.
  4. Use the command-line interface version of the program to answer the questions below.

Questions

Write your answers on the wall. Do others at your table get different answers? Figure out why.

  1. How many times does the name "Ophelia" appear in Hamlet?
  2. How many vowels are there in Hamlet?
  3. Count the number of times "AA" appears in the string "AAAAA" manually. Then get a Matcher to count them. Did you get the same number? Why or why not?
  4. Find all the email addresses in Hamlet (i.e. the Hamlet file from gutenberg.org). You'll need to think about how to use a regular expression to identify an email address.
  5. Find all the words in our big word list that contain at least one double letter (e.g. "moose" or "bookkeeper" or "ball").