Programming Hard

Python: Regular Expressions

Regular expressions are a powerful tool for searching, validating, and transforming text — and Python's re module makes them fully accessible. This quiz covers the syntax of regex patterns and the key functions in the re module.

Questions test knowledge of metacharacters (., *, +, ?, ^, $, []), character classes (\d, \w, \s), groups and capturing, re.search vs re.match vs re.findall, substitution with re.sub, and compiling patterns for reuse.

Regular expressions have a reputation for being hard to read — but once you understand the building blocks, they become an indispensable tool. This quiz tests whether you've crossed that threshold.

Start quiz → Opens in a new tab on Cletica

What This Quiz Covers

  • Metacharacters: . * + ? ^ $ | \ [ ] { } ( )
  • Character classes: \d (digit), \w (word), \s (whitespace), \b (boundary)
  • Quantifiers: * (0+), + (1+), ? (0 or 1), {n,m} (range)
  • Anchors: ^ (start), $ (end), \b (word boundary)
  • Groups: capturing () and non-capturing (?:)
  • re.search(), re.match(), re.findall(), re.finditer()
  • re.sub() for substitution and re.compile() for pattern reuse
Sample questions3 of 10 shown
Q1
What does the \d metacharacter match in a regular expression?
Q2
What is the difference between re.match() and re.search()?
Q3
Which pattern matches one or more digits?
Answer all 10 questions on Cletica →

Cletica

Want to create your own quiz?

Build surveys and quizzes, share with anyone, collect responses — free to start.

Try Cletica for free →