Introduction to Data - Multiple Choice Quiz
Last updated on 2023-04-24 | Edit this page
Overview
Questions
- What does
Fr[ea]nc[eh]
match?
Objectives
- Test knowledge of use of regular expressions in searches
Multiple Choice Quiz
This multiple choice quiz is designed to embed the regex knowledge you learned during this module. We recommend you work through it someone after class (within a week or so). Answers are on the answer sheet.
Q1. What is the special character that matches zero or more characters
^
#
*
Q2. Which of the following matches any space, tab, or newline?
\s
\b
$
Q3. How do you match the string Foobar
appearing at the
beginning of a line?
$Foobar
^Foobar
#Foobar
Q4. How do you match the word Foobar
appearing at the
beginning of a line?
^Foobar\d
^Foobar\b
^Foobar\w
Q5. What does the regular expression [a-z]
match?
- The characters a and z only
- All characters between the ranges a to z and A to Z
- All characters between the range a to z
Q6. Which of these will match the strings revolution
,
revolutionary
, and revolutionaries
?
revolution[a-z]?
revolution[a-z]*
revolution[a-z]+
Q7. Which of these will match the strings revolution
,
Revolution
, and their plural variants only?
[rR]evolution[s]+
revolution[s]?
[rR]evolution[s]?
Q8. What regular expression matches the strings dog
or
cat
?
dog|cat
dog,cat
dog | cat
Q9. What regular expression matches the whole words dog
or cat
?
\bdog|cat\b
\bdog\b | \bcat\b
\bdog\b|\bcat\b
Q10. What do we put after a character to match strings where that character appears 2 to 4 times in sequence?
{2,4}
{2-4}
[2,4]
Q11. The regular expression \d{4}
will match what?
- Any four character sequence?
- Any four digit sequence?
- The letter
d
four times?
- The letter
Q12. If brackets are used to define a group, what would match the
regular expression
(,\s[0-9]{1,4}){4},\s[0-9]{1,3}\.[0-9]
?
- , 135, 1155, 915, 513, 18.8
- , 135, 11557, 915, 513, 18.8
- , 135, 1155, 915, 513, 188
Key Points
- Regular expressions reference guide