← 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 →- Q1. What does this print? (code)
- Q2. Why should regex patterns be written as raw strings like r"\d"?
- Q3. Which function should you use to check that a whole input is a valid PIN code of 6 digits?
- Q4. What does [^aeiou] match?
- Q5. What does this print? (code)
- Q6. What does this print? (code)
- Q7. What is the difference between . and .??
- Q8. re.search(r"\d+", "no digits here") returns what?
- Q9. How do you match a real full stop in a pattern?
- Q10. What does re.split(r"[,;]\s", "a, b;c") return?