Multiline flag: TODO lines
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 test is a block of several lines. Capture the text after TODO: on every line that starts with TODO: (TODO, colon, space).
What this exercise teaches
^TODO: (.*)$ with the g and m flags finds every line that begins with TODO:. The dot does not cross line breaks, so each capture stays on its own line.
A hint if you get stuck
With the m flag, ^ and $ match at the start and end of every line, not just the whole text.
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.
More exercises in Advanced
- Lookahead: amounts before USDPro
- Negative lookahead: not starting with unPro
- Lookbehind: amounts after $Pro
- Negative lookbehind: positive numbers onlyPro
- Lazy vs greedy: the first quoted textPro
- Named groups: year, month, dayPro
- Password rules with lookaheadsPro
- Word boundaries: replace a whole wordPro
- Unicode letters with the u flagPro