Skills101
← All practice quizzes

Quiz: Regular Expressions in Python

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

Learn to find, check and clean text with patterns. Covers re.search, match, fullmatch, findall, sub and split, character classes, quantifiers, groups and validating phone numbers and emails.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What does this print?

    import re
    print(re.findall(r"\d+", "Rs 250 for 3 pens"))
    
  2. Question 2

    Why should regex patterns be written as raw strings like r"\d"?

  3. Question 3

    Which function should you use to check that a whole input is a valid PIN code of 6 digits?

  4. Question 4

    What does [^aeiou] match?

  5. Question 5

    What does this print?

    import re
    print(re.sub(r"(\w+)@(\w+)", r"\2@\1", "asha@home"))
    
🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →