Tasks
A goal in words, a corpus, and a step budget. You are graded on what your pattern does — the inputs it matches, the pieces it hands back, and what it cost to find out.
Literals and classes
- Just the numberswarm-up
Match a string made only of digits, and nothing else. A string with a space, a sign or a decimal point in it is not one.
2 min
- A name people actually haveroutine
Match a surname. Letters, and the two punctuation marks that appear in real surnames — an apostrophe and a hyphen — but not a space, a digit or anything else.
4 min
- Read the email validatorroutine
This is the email pattern that appears in a thousand codebases. Before running it, say which of these addresses it accepts. Three of them are real addresses that a person actually has.
read it · 5 min
Quantifiers and greed
- Inside the quotesroutine
Find every double-quoted section of a line, one per pair of quotes. A line with two quoted sections has two matches, not one long one.
4 min
- Under budgethard
Match a line that is entirely letters followed by an
@and more letters. It has to be right, and it has to stay inside the step budget on every input below — including the one that does not match.6 min
- Read the tag stripperhard
A pattern for pulling the contents out of a tag. Say what it matches in each line, and what group one comes back holding. One of these lines is the reason this pattern gets rewritten.
read it · 6 min
Anchors and boundaries
- The whole thing, not part of itwarm-up
Match a three-digit code, a hyphen and four more digits — and only when that is the entire input. A sentence containing one is not one.
3 min
- One word per lineroutine
Find every line that is a single word and nothing else. Blank lines and lines with a space in them do not count.
4 min
Groups, captures and backreferences
- Split the dateroutine
Match a date written as four digits, a hyphen, two digits, a hyphen, two digits — the whole string and nothing more — and capture the year, the month and the day, in that order, as three separate groups.
5 min
- The optional halfhard
Match a username, optionally followed by an
@and a host. Capture the username as group one and the host as group two. When there is no host, group two must take no part at all — not match an empty string.6 min
- Say it twicehard
Find a word repeated immediately after itself, separated by a single space. Capture the repeated word.
6 min
- Read the optional grouphard
A pattern that pulls a name and an optional title out of a line. For each input, say whether it matches and what each group comes back holding — and be exact about the difference between a group that matched nothing and one that never ran.
read it · 6 min
Alternation and order
- Yes or nowarm-up
Match a string that is exactly
yesor exactlyno. Nothing longer, nothing with either one inside it.3 min
- The longer numberroutine
Find the first number in the text, taking the decimal form when there is one.
12.5is one number, not a12followed by something. Do not anchor the pattern.5 min
Lookaround
- The number, not the unitroutine
Find every number that is immediately followed by a space and the letters
kg. The match must be the number alone — the space and the unit are not part of it.4 min
- Three requirements at oncehard
Match a string of at least eight characters that contains at least one lowercase letter, at least one uppercase letter and at least one digit. Any other character is allowed as well.
7 min
- Not after the signhard
Find every run of digits that is not immediately preceded by a dollar sign. A number at the very start of the input counts, because nothing precedes it.
6 min
Catastrophic backtracking
- Make it finishroutine
Match a string made only of the letter a, from start to end. The corpus includes a long run followed by one character that cannot match — the shape that turns a plausible pattern into a hang — and your answer has to stay inside the step budget on it.
5 min
- The quoted runhard
Match a whole string that is a pair of double quotes with anything except a quote between them. It has to be right, and it has to stay inside the budget on the unclosed quote at the end of the corpus.
6 min
- Read the hanghard
Here is a pattern with the shape that hangs. Before running it, say which of these inputs it matches — and bear in mind that one of them is the reason this task exists.
read it · 6 min
Unicode and flags
- Letters, in any scriptroutine
Match a string made entirely of letters — real letters, from any writing system, not just the twenty-six in the English alphabet. A digit, a space or an underscore disqualifies it.
4 min
- One character eachroutine
Match a string of exactly two characters — where a character means what a person would call one, so an emoji counts once rather than twice.
4 min
- Read the foldhard
This pattern is case-insensitive and unicode-aware. Say which of these inputs it matches. Two of them are characters you have probably never typed, and both of them fold onto letters you have.
read it · 6 min