PHP从字符串中提取网址

都知道python处理这些玩意儿方便,其实PHP也不差

$string = "The text you want to filter goes here. http://google.com, https://www.youtube.com/watch?v=K_m7NEDMrV0,https://instagram.com/hellow/";

preg_match_all('#bhttps?://[^,s()<>]+(?:([wd]+)|([^,[:punct:]s]|/))#', $string, $match);

echo "<pre>";
print_r($match[0]); 
echo "</pre>";