tags:

views:

34

answers:

1

I am busy with an application that uses transclusion. Basically I need to parse a given text and capture tags as follows:

  {{author: name |
    book : sometitle |
    year : someyear |
    img  : {{img:.....}}
  }}

My problem is that I need to recursively parse what is within the double curly brackets and replace it with other text. Is it possible to have recursion just using regex alone, can anyone offer a solution?

If you familiar with wiki text what I am doing is very similar.

+2  A: 

It can be done simply with regex and iteration, though MediaWiki doesn't use regex (except for parsing parameters). See the braceSubstitution function in includes/parser/Parser.php

wallyk