A solution not using regex:
- Explode the string at '*'
- Ditch the parts starting with '{';
- Remove all the brackets
- Explode the String at 'space'
- The first part is the link
- Glue back together the rest for the description
The code:
$parts=explode('*',$str);
$links=array();
foreach($parts as $k=>$v){
$parts[$k]=ltrim($v);
if(substr($parts[$k],0,1)!=='['){
unset($parts[$k]);
continue;
}
$parts[$k]=preg_replace('/\[|\]/','',$parts[$k]);
$subparts=explode(' ',$parts[$k]);
$links[$k][0]=$subparts[0];
unset($subparts[0]);
$links[$k][1]=implode(' ',$subparts);
}
echo '<pre>'.print_r($links,true).'</pre>';
The result:
Array
(
[1] => Array
(
[0] => http://www.bbc.co.uk/news/world-europe-17298730
[1] => France from the BBC News
)
[2] => Array
(
[0] => http://ucblibraries.colorado.edu/govpubs/for/france.htm
[1] => France at ''UCB Libraries GovPubs''
)
[4] => Array
(
[0] => http://www.britannica.com/EBchecked/topic/215768/France
[1] => France ''Encyclopædia Britannica'' entry
)
[5] => Array
(
[0] => http://europa.eu/about-eu/countries/member-countries/france/index_en.htm
[1] => France at the European Union|EU
)
[8] => Array
(
[0] => http://www.ifs.du.edu/ifs/frm_CountryProfile.aspx?Country=FR
[1] => Key Development Forecasts for France from International Futures ;Economy
)
[10] => Array
(
[0] => http://stats.oecd.org/Index.aspx?QueryId=14594
[1] => OECD France statistics
)
)