I can't think of one or more perl-compatible regular expressions (PCRE) to
match a 'block' in the following string:
{#begin block1}
bla bla
{#begin block2}
bla bla
this is a nested block in block1
{#end} //end of block2
{#begin block3}
bla bla
this is a nested block in block1
{#begin block4}
bla bla
this is a nested block in block1 and block 3
{#end} //end of block4
{#end}//end of block3
this the root block1
{#end} //end of block1
(indent: 2 whitespaces)
How can I match the contents of one block?
"/{#begin $blockname}(.?){#end}/" is the one I can think of, but it
matches wrong, of course, because there are nested blocks.
Does anyone have an idea how to match it right?
I know I can use {#begin block1}...{#end block1} to make nested blocks
easier to match (pattern: "/{#begin $blockname}(.?){#end
$blockname}/"), but that is not what I want.