Quiz Python: 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.

Medio 10 domande ~6 minuti Superato con il 80% Python 3.12

Scegli una modalità

Stai giocando come ospite: accedi per salvare XP e serie.

Domanda di esempio

Domanda 1 di 10

What does this print?

import re

print(re.findall(r"\d+", "a1b22c333"))
Mostra la risposta

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.

Cosa copre questo 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

Domande frequenti

Serve un account?

No. Chiunque può giocare. Accedi per salvare XP, serie, badge e cronologia.

Quale versione di Python?

Python 3.12. Ogni domanda sull'output è stata verificata eseguendo il codice.

Posso rifarlo?

Sì. Il tuo miglior punteggio resta salvato, e domande e risposte vengono mescolate ogni volta.