IT 117: Intermediate to Scripting
Answers to Class 12 Ungraded Quiz

  1. If you wanted to match the characters "ox" when they were not at the beginning of a string, what regular expression would you use?
    .*ox
  2. What meta-characters do you use to surround a part of a regular expression that you want to extract from the matched string?
    ( )
  3. 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
  4. What does the $ in a regular expression mean?
    the end of a string
  5. What does the | in a regular expression mean?
    it is a logical or
  6. What is a greedy match?
    a match with the greatest number of characters
  7. What regular expression would you write if you wanted to match ONE occurrence of either the character "x", or "y", or "z"?
    [xyz]
  8. What regular expression would you write if you wanted to match a SINGLE lowercase character?
    [a-z]
  9. What regular expression would you write if you wanted to match exactly 57 occurrences of the letter "X"
    X{57}
  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}