I need to extract the all url's from the string using php , I refered below url but not getting exact result I want. Reference url and my string are below,
$string = "hi new image one http://xxx/images/c4ca4238a0b923820dcc509a6f75849b208754572.jpgand two arehttp://yyy/images/c1f1a611c1147c4054c399c01f8bad76686484492.jpgend";
$regex = '#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#';
preg_match_all($regex, $string, $matches);
echo "<pre>";
print_r($matches[0]);
am getting result are
Array
(
[0] => http://xxx/images/c4ca4238a0b923820dcc509a6f75849b208754572.jpgand
)
It shows only one result , but in string 2url's are available, is it possible to get below result,
Array
(
[0] => http://xxx/images/c4ca4238a0b923820dcc509a6f75849b208754572.jpg
[1] => http://yyy/images/c1f1a611c1147c4054c399c01f8bad76686484492.jpg
)
How to remove appending text in front and end of url and filter exact url's from string ? Any help Appreciated