key=value pairs
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
Lines hold key=value pairs separated by semicolons. Capture every pair: the key (word characters) in group 1 and the value (everything up to the next semicolon, possibly empty) in group 2.
What this exercise teaches
(\w+)=([^;]*) reads the key, then everything that is not a semicolon, so values with spaces and empty values both work.
A hint if you get stuck
A negated class like [^;]* stops at the separator, whatever the value contains.
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.