Regexdrill

Level 4: Extraction and cleanup Exercise 32 of 52 Pro

Log lines: level and message

A regex exercise from Regexdrill. Solve it with a pattern box with live highlighting in your browser, checked against hidden test strings, and it is checked the moment you submit.

The task

Each log line has a level in square brackets, like [ERROR], followed by a space and a message. Capture the capitalized level in group 1 and the rest of the line in group 2.

What this exercise teaches

\[([A-Z]+)\] (.+) only lets capital letters inside the brackets, so a later [admin] in the message cannot be swallowed into the level.

A hint if you get stuck

Escape the brackets. A greedy .* inside the brackets can run past the first closing bracket.

This exercise is part of Pro

Pro unlocks all 52 exercises, with worked solutions and progress saved to your account. The free exercises work without an account.

You create a free account first, so Pro is attached to it.

Monthly is charged today and then every month until you cancel, in one click from your account page. Lifetime is one payment with no renewals. Full refund within 14 days of paying.

Start with the free exercises

More exercises in Extraction and cleanup