Go to: LING 1330/2330 home page  

Extra Credit: Regular Expressions

This is an extra credit assignment. You can earn up to 10 extra points towards your homework assignment total. 90--100% will get you 10 points, 80--89.99% will get you 9 points, etc.

The goal is to help you get a head start on regular expressions, which is our next big topic. Study section 2.1 "Regular Expressions" of this Jurafsky & Martin chapter, and work on the questions below. Then, check your answers through the "extra credit quiz" portal on Canvas.

  1. /[Ll]ing/ is the regular expression. Which of the following strings does it match? Pick all.
    1. "I like linguine"
    2. "I Like Linguistics Very Much"
    3. "I'm taking computational linguistics and sociolinguistics"
    4. "I'm a Ling major"
    5. "I'm a CS major"
  2. /[a-z][A-Z][a-z]+/ is the regular expression. Which of the following strings does it match? Pick all.
    1. "Microsoft"
    2. "iPhone"
    3. "OS X"
    4. "iPad"
    5. "DuoLingo"
  3. /[0-9]/ is the regular expression. Which of the following regular expressions are equivalent? Pick all.
    1. /[0123456789]/
    2. /[1234567890]/
    3. /\d/
    4. /\D/
  4. /hello*/ is the regular expression. Which of the following strings does it NOT match? One answer.
    1. "hello"
    2. "helloooooo, world!"
    3. "Hellohellohello"
    4. "what fresh hell is this?"
    5. "Hello, world!"
  5. /.\./ is the regular expression. Which of the following strings does it match? Pick all.
    1. "aa"
    2. "a."
    3. ".."
    4. ".a"
    5. "a.a"
  6. /(thank|joy|taste|thought)(ful|less)?/ is our regular expression. Which one of the following strings does it NOT match?
    1. "thank"
    2. "taste"
    3. "tasteful"
    4. "joyless"
    5. "less"
  7. Suppose we're trying to find all Austen sentence strings with the word 'so', ignoring case. Note that we must also take care not to produce false positives like 'song' and 'handsome'. What's the regular expression to use?
    1. /so/
    2. / (so|So|SO|sO) /
    3. /\bso\b/
    4. /\b[Ss][Oo]\b/
    5. /^so$/
  8. Suppose we're trying to find all Austen sentence strings ending with a question mark '?'. What's the regular expression to use?
    1. /?/
    2. /\?/
    3. /?$/
    4. /\?$/
  9. /[aeiou]{4}/ is the regular expression. Which of the following strings does it match? Pick all.
    1. "keep"
    2. "gracious"
    3. "sequoia"
    4. "queueing"
  10. /t[^aeiou][aeiou]/ is the regular expression. Which of the following strings does it match? Pick all.
    1. "tea"
    2. "stain"
    3. "street"
    4. "butter"
  11. Which of the following are anchors, also known as place indicators? Pick all.
    1. $
    2. ^
    3. *
    4. \s
    5. \b
  12. /\w+/ is a regular expression that positively matches the string "##iPhone6##". But what exact part of this string does it match? The matched substring portion is underlined below.
    1. "##iPhone6##"
    2. "##iPhone6##"
    3. "##iPhone6##"
    4. "##iPhone6##"
    5. "##iPhone6##"
  13. /\W\w+\W/ is a regular expression that also positively matches the string "##iPhone6##". But what exact part of this string does it match this time? The matched substring portion is underlined below.
    1. "##iPhone6##"
    2. "##iPhone6##"
    3. "##iPhone6##"
    4. "##iPhone6##"
    5. "##iPhone6##"
  14. /'.*'/ is a regular expression that was meant to match quoted phrases. It positively matches the long text string below. But what exact part(s) of this string does it match? The matched substring portions are underlined. (keyword: greediness of *)
    1. "She said 'hello there', and I said 'hi' back."
    2. "She said 'hello there', and I said 'hi' back."
    3. "She said 'hello there', and I said 'hi' back."
  15. /the (.*)er they were, the \1er they will be/ is a regular expression which utilizes the concept of capture group. Which of the following strings does it NOT match? One answer.
    1. "the bigger they were, the bigger they will be"
    2. "the bigger they were, the hungrier they will be"
    3. "the er they were, the er they will be"
    4. "the XYZer they were, the XYZer they will be"
SUBMIT:
  • Answer the 20 15 quiz questions through Canvas.
  • You have unlimited attempts until the deadline: 10/17 (Thu) 9am.
  • After each attempt, you will be able to see which questions you got wrong but not the correct answers.
  • At 9:05am, the Canvas quiz will unlock the answer key, and you'll be able to see the correct answers. Make sure to check them: regular expressions can be a real head-scratcher sometimes.