I have a text string structured as follows:
= Some Heading (1)
Some text
== Some Sub-Heading (2)
Some more text
=== Some Sub-sub-heading (3)
Some details here
= Some other Heading (4)
I want to extract the contents of the second header, including any subsection. I do not know in advance what the depth of the second heading is, so I need to match the next heading from there, which has the same depth, or shallower, or the end of the line.
In the above example, this will give:
== Some Sub-Heading (2)
Some more text
Some details here
This is where I am stuck. How can I use a consistent subexpression by opening the second header as part of the subexpression to close the section.
Mathieu dd
source
share