$re = '/(?=\{Infobox)(\{([^{}]|(?1))*\})/m';
$str = '
<?xml version="1.0"?><api><query><pages><page pageid="5843419" ns="0" title="France"><revisions><rev contentformat="text/x-wiki" contentmodel="wikitext" xml:space="preserve">{{about|the country}}
{{Use dmy dates|date=November 2013}}
{{EngvarB|date=November 2013}}
{{see also|Portal:France{{!}}France portal|Outline of France}}
{{pp-semi|small=yes}}{{pp-move-indef}}
{{Infobox country
|conventional_long_name = French Republic
|native_name = {{native name|fr|République française|icon=no}}
|common_name = France
|image_flag = Flag of France.svg
|demonym = French
|government_type = [[Unitary state|Unitary]] [[Semi-presidential system|semi-presidential]] [[republic|constitutional republic]]
|leader_title1 = [[President of France|President]]
|leader_name1 = [[François Hollande]]
|calling_code = [[Telephone numbers in France|+33]]{{refn|group=note|name=eleven|The overseas regions and collectivities form part of the [[French telephone numbering plan]], but have their own country calling codes: [[Guadeloupe]] +590; [[Martinique]] +596; [[French Guiana]] +594, [[Réunion]] and [[Mayotte]] +262; [[Saint Pierre and Miquelon]] +508. The overseas territories are not part of the French telephone numbering plan; their country calling codes are: [[New Caledonia]] +687, [[French Polynesia]] +689; [[Wallis and Futuna]] +681.}}
|ISO_3166-1_alpha2 =
|ISO_3166-1_alpha3 = FRA
|ISO_3166-1_numeric =
|sport_code = FRA
|vehicle_code = F
|cctld = [[.fr]]{{refn|group=note|name=ten|In addition to [[.fr]], several other Internet TLDs are used in French overseas \'\'départements\'\' and territories: [[.re]], [[.mq]], [[.gp]], [[.tf]], [[.nc]], [[.pf]], [[.wf]], [[.pm]], [[.gf]] and [[.yt]]. France also uses [[.eu]], shared with other members of the European Union. The [[.cat]] domain is used in [[Catalan Countries|Catalan-speaking territories]].}}
}}
\'\'\'France\'\'\' ({{IPAc-en|UK|ˈ|f|r|É‘Ë|n|s}}; {{IPAc-en|US|audio=en-us-France.ogg|ˈ|f|r|æ|n|s}}; {{IPA-fr|fÊɑ̃s|lang|France.ogg}}), officially the \'\'\'French Republic\'\'\' ({{lang-fr|link=no|République française}} {{IPA-fr|Êepyblik fÊɑ̃sÉ›z|}}), is a sovereign country in [[Western Europe]] that includes [[Overseas departments and territories of France|overseas regions and territories]].{{refn|group=note|name=twelve|[[French Guiana]] is located in [[South America]]; [[Guadeloupe]] and [[Martinique]] are in the [[Caribbean]]; and [[Réunion]] and [[Mayotte]] are in the [[Indian Ocean]], off the coast of [[Africa]]. All five [[Administrative divisions of France#Overseas|are considered integral parts of the republic]].}} [[Metropolitan France]] extends from the [[Mediterranean Sea]] to the [[English Channel]] and the [[North Sea]], and from the [[Rhine]] to the [[Atlantic Ocean]]. It is one of only three countries (besides [[Morocco]] and [[Spain]]) to have both Atlantic and Mediterranean coastlines. Due to its shape, it is often referred to in French as \'\'{{lang|fr|l’Hexagone}}\'\' ("The [[Hexagon]]").
France is the largest country in [[Western Europe]] and the [[European Union]], and the third-largest in Europe as a whole. With a total population of around 66 million, it is the [[List of European countries by population|third most-populous]] European country. France is a [[Unitary state|unitary]] [[Semi-presidential system|semi-presidential]] [[republic]] with its [[Capital city|capital]] in [[Paris]], the nation\'s largest city and the main cultural and commercial centre. The current [[Constitution of France]], adopted by referendum on 4 October 1958, establishes the country as secular and democratic, with its sovereignty derived from the people. The nation\'s ideals are expressed in the foundational \'\'[[Declaration of the Rights of Man and of the Citizen]]\'\', one of the world\'s earliest documents on human rights, which was formulated during the seminal [[French Revolution]] of the late 18th century.
France has been a major power in Europe since the [[Late Middle Ages]], reaching the height of its influence during the 19th and early 20th centuries, when it possessed the [[French colonial empire|second-largest colonial empire]] of the time, and one of the largest in history. This legacy is reflected in the prevalence of [[French language]], [[Culture of France|culture]], and [[Napoleonic Code|jurisprudence]] worldwide. France has produced many influential artists, thinkers, and scientists, and remains a prominent global centre of culture. It hosts the world\'s [[List of World Heritage Sites in France|fourth-largest]] number of cultural [[UNESCO World Heritage Sites]], drawing around 83 million foreign tourists annually – the most of any country in the world.<ref name="tourism.stat">{{cite web |publisher= United Nations World Tourism Organization |url=http://dtxtq4w60xqpw.cloudfront.net/sites/all/files/pdf/unwto_highlights13_en_lr.pdf |title=UNWTO Highlights |accessdate=11 September 2013|format=PDF}}{{dead link|date=January 2014}}</ref>
France remains a [[major power]] with signif';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php