I'm currently developing a parser for my own content management system. I'm using Perl-Compatible RegExps to parse strings, but I'm stuck right now. The problem I'm having is to allow nested matches inside a match, if you understand what I mean.
The current pattern looks like the following:
'#<\{if\((.*?)\)\}>(.*?)<\{endif\}>#s
What the string could look like:
<{if(statement)}>Some text which is outputted if statement equals to true.<{if(statement2)}> This text will be outputted if both statement and statement2 equals to true.<{endif}><{endif}>
The current pattern would just match anything between <{if(statement)}> and the first <{endif}>, and not to the last <{endif}>, as it should.
I need help with making it aware of nested matches. Are there any RegExp Gurus out there who can help me with this?
Thanks in advance //vigge