I need to extract the first URL from some content. The content may be like this
({items:[{url:"http://cincinnati.ebayclassifieds.com/",name:"Cincinnati"},{url:"http://dayton.ebayclassifieds.com/",name:"Dayton"}],error:null});or may contain only a link
({items:[{url:"http://portlandor.ebayclassifieds.com/",name:"Portland (OR)"}],error:null});
currently I have :
$pattern = "/\:\[\{url\:\"(.*)\"\,name/"; preg_match_all($pattern, $htmlContent, $matches); $URL = $matches[1][0];
however it works only if there is a single link so I need a regex which should work for the both cases.