Embercode
✕
StringsQuick quiz

Words and regex

8 questions. Covers Regex basics with the Python re module.

Questions 1 to 5 of 8

  1. 1. What does this program print? ``python print(' x y '.split(' ')) ``
  2. 2. Which regex piece matches exactly one digit from 0 to 9? Write it as it appears inside a raw string, without the r and the quotes.

    Type your answer.

  3. 3. Without the r prefix, how many backslash characters must you type in a Python string literal to get one backslash into the pattern? Give the number.

    Type your answer.

  4. 4. Why does this call return None? ``python import re print(re.fullmatch(r'\d{3}-\d{4}', 'call 555-1234 now')) ``
  5. 5. What does this program print? ``python import re print(re.sub(r'\d+', '#', 'order 17 shipped, order 204')) ``

5 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.