Exsample
preg_replace('/\{[a-zA-Z.,\(\)0-9]+\}/', 'Replaced', 'Lorem ipsum dolor sit {tag1({tag2()})}, consectetur adipiscing elit.');
The result:
Lorem ipsum dolor sit {tag1(Replaced)}, consectetur adipiscing elit.
Question
As you can see "tag2" has been replaced, But i whant to replace "tag1" Do anyone know how i can do this?
(In some cases it might be like this: {tag1({tag2({tag3()})})})
and so on.)
Btw iam actually using preg_replace_callback, but its easyer to show it with preg_replace
Here is a site where you can test the code: http://www.spaweditor.com/scripts/regex/index.php