🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Regular Expressions in Python: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. What does this print? (code)
  2. Q2. Why should regex patterns be written as raw strings like r"\d"?
  3. Q3. Which function should you use to check that a whole input is a valid PIN code of 6 digits?
  4. Q4. What does [^aeiou] match?
  5. Q5. What does this print? (code)
  6. Q6. What does this print? (code)
  7. Q7. What is the difference between . and .??
  8. Q8. re.search(r"\d+", "no digits here") returns what?
  9. Q9. How do you match a real full stop in a pattern?
  10. Q10. What does re.split(r"[,;]\s", "a, b;c") return?