Introduction to Computer Science
CompSci 101 : Fall 2013

Regular Expressions Pop Quiz

Part A

For each of the following regular expressions, circle all of the strings from the choices that it would match.

  1. ^a+
    • abcba
    • bcdef
    • bcaca
    • bbacb
    • aacbb

  2. b+ac?
    • abcba
    • bcdef
    • bcaca
    • bbacb
    • aacbb

  3. ^a\w*a$
    • abcba
    • bcdef
    • bcaca
    • bbacb
    • aacbb

  4. a\w?a
    • abcba
    • bcdef
    • bcaca
    • bbacb
    • aacbb

Part B

The following two strings are codons for the protein Asparagine, abbreviated as N.

'aat', 'aac'

Write a regular expression that matches those two, and only those two, strings. You can assume that your regular expression will be matched only on strings that are three letters long, containing only the letters 'g', 't', 'a', and 'c'.