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.
- /[Ll]ing/ is the regular expression. Which of the following strings does it match? Pick all.
- "I like linguine"
- "I Like Linguistics Very Much"
- "I'm taking computational linguistics and sociolinguistics"
- "I'm a Ling major"
- "I'm a CS major"
- /[a-z][A-Z][a-z]+/ is the regular expression. Which of the following strings does it match? Pick all.
- "Microsoft"
- "iPhone"
- "OS X"
- "iPad"
- "DuoLingo"
- /[0-9]/ is the regular expression. Which of the following regular expressions are equivalent? Pick all.
- /[0123456789]/
- /[1234567890]/
- /\d/
- /\D/
- /hello*/ is the regular expression. Which of the following strings does it NOT match? One answer.
- "hello"
- "helloooooo, world!"
- "Hellohellohello"
- "what fresh hell is this?"
- "Hello, world!"
- /.\./ is the regular expression. Which of the following strings does it match? Pick all.
- "aa"
- "a."
- ".."
- ".a"
- "a.a"
- /(thank|joy|taste|thought)(ful|less)?/ is our regular expression. Which one of the following strings does it NOT match?
- "thank"
- "taste"
- "tasteful"
- "joyless"
- "less"
- 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?
- /so/
- / (so|So|SO|sO) /
- /\bso\b/
- /\b[Ss][Oo]\b/
- /^so$/
- Suppose we're trying to find all Austen sentence strings ending with a question mark '?'. What's the regular expression to use?
- /?/
- /\?/
- /?$/
- /\?$/
- /[aeiou]{4}/ is the regular expression. Which of the following strings does it match? Pick all.
- "keep"
- "gracious"
- "sequoia"
- "queueing"
- /t[^aeiou][aeiou]/ is the regular expression. Which of the following strings does it match? Pick all.
- "tea"
- "stain"
- "street"
- "butter"
- Which of the following are anchors, also known as place indicators? Pick all.
- $
- ^
- *
- \s
- \b
- /\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.
- "##iPhone6##"
- "##iPhone6##"
- "##iPhone6##"
- "##iPhone6##"
- "##iPhone6##"
- /\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.
- "##iPhone6##"
- "##iPhone6##"
- "##iPhone6##"
- "##iPhone6##"
- "##iPhone6##"
- /'.*'/ 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 *)
- "She said 'hello there', and I said 'hi' back."
- "She said 'hello there', and I said 'hi' back."
- "She said 'hello there', and I said 'hi' back."
- /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.
- "the bigger they were, the bigger they will be"
- "the bigger they were, the hungrier they will be"
- "the er they were, the er they will be"
- "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.
|
|
|