Skip to content

Catastrophic backtracking

·

predict · hard

Read the hang

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.

//
^+$
^(?:\w+\s?)+$
^(?:)+$
^(?:+?)+$

Your prediction

One row per input: whether it matches, and what each group captures
InputMatches?
one two
one
one two three
one two!
(empty)
Nothing runs until you have answered every row.