What reg expression patten to I need to match everything between {{ and }}
I'm trying to parse wikipedia, but im ending up with orphan }} after running the rexex code. Here's my PHP script.
<?php
$articleName='england';
$url = "http://en.wikipedia.org/wiki/Special:Export/" . $articleName;
ini_set('user_agent','custom agent'); //required so that Wikipedia allows our request.
$feed = file_get_contents($url);
$xml = new SimpleXmlElement($feed);
$wikicode = $xml->page->revision->text;
$wikicode=str_replace("[[", "", $wikicode);
$wikicode=str_replace("]]", "", $wikicode);
$wikicode=preg_replace('/\{\{([^}]*(?:\}[^}]+)*)\}\}/','',$wikicode);
print($wikicode);
?>
I think the problem is I have nested {{ and }} e.g.
{{ something {{ something else {{ something new }}{{ something old }} something blue }} something green }}