IT 117: Intermediate Scripting
Quiz 4 Answers

  1. What are three things are found in a regular expression?
    ordinary characters, meta-characters, character classes
  2. What does the . (dot) in a regular expression match?
    one occurrence of any character, except the newline
  3. What does the * in a regular expression match?
    0 or more occurrences of the character that comes before it
  4. What does the + in a regular expression match?
    1 or more occurrences of the character that comes before it
  5. What does \d in a regular expression match?
    a single digit
  6. What meta-characters do you use to surround a part of a regular expression that you want to extract from the matched string?
    ( )
  7. What method on a match object is used to extract the value of a string in a matched line using the meta-characters mentioned above?
    group
  8. What is a greedy match?
    a match with the greatest number of characters
  9. What regular expression would you write if you wanted to match one occurence of either the character "x", or "y", or "z"?
    [xyz]
  10. What regular expression would you write if you wanted to match anywhere between 3 and 5 occurrences of the letter "q"?
    q{3,5}