Quiz de 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.

Médio 10 perguntas ~6 minutos Aprovação com 80% Python 3.12

Escolha um modo

Jogando como visitante: entre para guardar seu XP e sua sequência.

Pergunta de exemplo

Pergunta 1 de 10

What does this print?

import re

print(re.findall(r"\d+", "a1b22c333"))
Mostrar a resposta

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.

O que este quiz cobre

  • 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

Perguntas frequentes

Preciso de uma conta?

Não. Qualquer pessoa pode jogar. Entre para guardar seu XP, sequência, badges e histórico.

Qual versão do Python?

Python 3.12. Toda pergunta sobre a saída foi conferida rodando o código.

Posso refazer?

Pode. Sua melhor nota fica salva, e as perguntas e respostas são embaralhadas a cada vez.