Hi I'm working on a bug in a CMS and I was hoping someone could give me some help with this messy regex! I need to remove everything inside the {{page? }} tags (where 'page' is a dynamic word), including any nested {{tags}} within them.- except for {{links? }}
In the code below, the regex should remove everything inside the {{homepage? }} tag:
<div id="main">
<div id="left">
{{menu1}}<br />
{{homepage?
<img src="images/{{timenow}}.gif" width="177" height="217" alt="{{imgname}}" id="biglogo" />
}}
{{links?
<b>LINKS</b>
}}
</div>
{{menu2}}
</div>
Here's what I have so far. It's getting stuck as soon as it sees the timenow}}
$result=preg_replace("#\{\{(?!links)\S*?\?.*?}}#s","",$result);
Clarification:
There are no {{page? }} sub tags (all subtags are {{thisformat}} ).
In other words something like: {{foo? {{links? bar }} baz }} would never occur.
{{page? }}tags? You mean{{homepage? ... }}? Do you actually want to remove all tags except the links tag? What what happen with{{foo? {{links? bar }} baz }}? Or do you just want to grab the content of links tag(s)?(?R)syntax. In your case you might get away with:"#\{\{(?!links)\w+\?((?R)|.)*}}#s"- but the.should be rewritten to something more specific.{{page? }}I meant the word page is dynamic (can be any single word like homepage, links, contact, etc). There are no {{page? }} sub tags (all subtags are {{thisformat}} ) so your example would never occur. @mario - looks promising. I'll give it a blast and report back.