I'm receiving string from the Wikipedia APi which look like this:
{{Wikibooks|Wikijunior:Countries A-Z|France}} {{Sister project links|France}} * [http://www.bbc.co.uk/news/world-europe-17298730 France] from the [[BBC News]] * [http://ucblibraries.colorado.edu/govpubs/for/france.htm France] at ''UCB Libraries GovPubs'' *{{dmoz|Regional/Europe/France}} * [http://www.britannica.com/EBchecked/topic/215768/France France] ''Encyclopædia Britannica'' entry * [http://europa.eu/about-eu/countries/member-countries/france/index_en.htm France] at the [[European Union|EU]] *{{Wikiatlas|France}} *{{osmrelation-inline|1403916}} * [http://www.ifs.du.edu/ifs/frm_CountryProfile.aspx?Country=FR Key Development Forecasts for France] from [[International Futures]] ;Economy *{{INSEE|National Institute of Statistics and Economic Studies}} * [http://stats.oecd.org/Index.aspx?QueryId=14594 OECD France statistics]
I have to use both the actual url's, and the description of the url. So for example, for [http://www.bbc.co.uk/news/world-europe-17298730 France] from the [[BBC News]] I need to have "http://www.bbc.co.uk/news/world-europe-17298730" and also "France] from the [[BBC News]] " but without the brackets, like so "France from the BBC News".
I managed to get the first parts, by doing the following:
if(preg_match_all('/\[http(.*?)\s/',$result,$extmatch)) {
$mt= str_replace("[[","",$extmatch[1]);
But I don't know how to go around getting the second part (I'm quite weak at regex unfortunately :-( ).
Any ideas?