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
| Input | Matches? |
|---|---|
| one two | |
| one | |
| one two three | |
| one two! | |
| (empty) |
Nothing runs until you have answered every row.