Exercise

Regular Expression Lab: Practice on Real arXiv Text

A lab for regular expressions: type a pattern, see what it fits in real text from arXiv, and read an explanation of every part of the pattern. Five challenges on the numbers of pages, identifiers, sizes, dates and subject codes.

Last updated:


This page is a workshop for the patterns of Patterns in Text: Regular Expressions.
Type a pattern, and the lab marks what it fits in a real text from arXiv, lists the matches and the groups, and explains every part of the pattern in plain words.
Select a row of the explanation to see its part of the pattern.

A free lab

Choose a text, write a pattern, and watch the matches change.
The lab runs the patterns that the lesson teaches, in the way Python does.

Challenges

In each challenge the lab compares your pattern with the expected items.
The items are what re.findall returns: the whole match, or the text of the group when the pattern has a group.
The texts are real: comments, identifiers, submission lines and subjects of the arXiv pages of the lesson.

The number of pages

The identifiers

The size of the submission

The dates

The codes of the subjects

Exercise generator

Each exercise draws a real text and says what to extract. Write a pattern and press Check:
a wrong pattern gets the differences marked on the text and a hint about the reason.
The exercise number can be shared, so that a whole class works on the same one.