I am trying to catch specific list items with regex:
> check listId
> - [v] catch me
> - [x] skip me
> - [ ] catch me too
> ignore thislistId
> - [v] ignore me
> - [x] ignore me also
> - [ ] ignore me too
Expected matched result is
> - [v] catch me
> - [ ] catch me too
This regex works, except like this the regex ignores the listId:
\> - \[(v| )\]\s?[a-z].*\n?
If I precede with a non-capturing group on the listId, the output breaks after the first bullet:
(?:\> check listId\n)(\> - \[(v| )\]\s?[a-z].*\n?)
What is a better approach?
You can use
See the regex demo.
Details:
(?<=^> check listId(?:\n> - .*)*\n)> - \[[v ]]- a> - [v]or> - [ ]substring\s?- n optional whitespace[a-z]- a lowercase ASCII letter.*\n?- the rest of the line and an optional newline char.