Skip to content

Instantly share code, notes, and snippets.

@IsmailShurrab
Created January 12, 2019 08:59
Show Gist options
  • Save IsmailShurrab/cc8fdae9931533c4930241b3dcd9f9e4 to your computer and use it in GitHub Desktop.
Save IsmailShurrab/cc8fdae9931533c4930241b3dcd9f9e4 to your computer and use it in GitHub Desktop.
extract urls rejex
$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()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $string, $match);
echo "<pre>";
print_r($match[0]);
echo "</pre>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment