I'm trying to match blocks of text that contain certain text within them. Each block is clearly defined by standard start/end text patterns.
In the below example I want to match steps 1 and 3 from the "step start" to "step end" as they contain the text "database:dev". However my current regex matches step 1 fine, but then matches steps 2 and 3 in a single match. It's probably easier to see with an example here: https://regex101.com/r/56tfOQ/3/
I need to specify that each match can only contain one "step start", but I can't work out how to do that.
The regex I'm currently using is:
(?msi)step start.*?database:dev.*?step end
An example of the text is:
step start
name:step1
database:dev1
step end
step start
name:step2
database:test1
step end
step start
name:step3
database:dev2
step end
step start
name:step4
database:test2
step end