Python-Quiz: Regular Expressions (re)

This Python quiz tests the re module and the regular expression syntax you use most. You will predict what findall, search, match, sub and split return, and learn to spot greedy patterns, missing raw strings and None results.

Mittel 10 Fragen ~6 Minuten Bestanden ab 80% Python 3.12

Modus wählen

Du spielst als Gast: Melde dich an, damit XP und Serie gespeichert werden.

Beispielfrage

Frage 1 von 10

What does this print?

import re

print(re.findall(r"\d+", "a1b22c333"))
Lösung zeigen

C. ['1', '22', '333'] \d+ matches one or more digits in a row, and findall returns every match as a string. Without the + you would get each digit separately.

Darum geht es in diesem Quiz

  • search vs match vs fullmatch
  • findall with and without groups
  • Greedy vs lazy quantifiers
  • Groups and back-references in re.sub
  • Raw strings and checking for None

Häufige Fragen

Brauche ich ein Konto?

Nein. Jeder kann spielen. Mit Anmeldung werden XP, Serie, Abzeichen und Verlauf gespeichert.

Welche Python-Version?

Python 3.12. Jede Frage zur Ausgabe wurde geprüft, indem der Code ausgeführt wurde.

Kann ich es wiederholen?

Ja. Dein Bestwert bleibt erhalten, und Fragen und Antworten werden jedes Mal neu gemischt.