I am making a template parsing program. This part will parse code blocks from the template. It is an iterator that takes the values from a list and prints them how the block says. Much like Smarty PHP template.

Template file:
<table width="100" border="1" bgcolor="#490903">
{iterate name="i" list="list1"}


something in between blocks!

<table width="100" border="1" bgcolor="#490903">

{iterate name="i" list="list2"}

My problem is getting the text in between the iterate blocks. I don't know how to fine tune a regex to get just the inbetween stuff. Otherwise it is just removed.

I have tried this to get the between text : \{iterate name=\".*?\" list=\".*?\"\}.*?\{/iterate\}(.*?)\{iterate name=\".*?\" list=\".*?\"\}.*?\{/iterate\}

It works, with re.split, but it gets a bunch of unwanted matches along with the correct ones. Weeding them out isn't working. Is there a way to make a regex to find just what is between {iterate}{/iterate} blocks? Everything I have tried gives unwanted matches.