dimanche 27 août 2017

PHP: RegEx for nested {IF} {ENDIF} Conditions

I am searching the whole day for a RegEx that matches just the inner {IF} - {ENDIF}-Statement in a nested condition code. Does anyone have an idea?

for example:

{IF bla}Text 1{ELSEIF ble}Text 2 {IF bli}Text 2.1{ELSE blo}Text 2.1{ENDIF} Main text end{/ENDIF}

I just want to get

{IF bli}Text 2.1{ELSE blo}Text 2.1{ENDIF}

i tried #\{IF .*\}.*\{ENDIF\}#is but this is not working as i only get the whole string.

And also important: The code can have several lines and line breaks!

the bla, ble, bli etc are dynamic and can differ

Aucun commentaire:

Enregistrer un commentaire