Extract URL's from a string using PHP
REGEX is the answer for your problem. Taking the Answer of Object Manipulator.. all it's missing is to exclude "commas", so you can try this code that excludes them and gives 3 separated URL's as output:
$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>";
and the output is
Array
(
[0] => http://google.com
[1] => https://www.youtube.com/watch?v=K_m7NEDMrV0
[2] => https://instagram.com/hellow/
)
extract specific URLs from text
What you are looking for is a negative lookahead:
$regex = '/https?:\/\/(?!\[GoTo\]|\[NextURL\]|[^\" ]*\/i\/[^\" ]+|[^\" ]*\/t\/[^\" ]*)[^\" ]+/i';
?! at the beginning of a submatch should prevent matching for URLs with the enclosed pattern. This might need tweaking for specific corner cases, but with the problem as stated, this should get you what you need.
Related Topics
Working With Large Numbers in PHP
PHP Preg_Match With Working Regex
How to Convert a Pdf Document to a Preview Image in PHP
"Date(): It Is Not Safe to Rely on the System'S Timezone Settings..."
Highlight the Difference Between Two Strings in PHP
Fatal Error: Uncaught Error: Call to Undefined Function MySQL_Connect()
Delimiter Must Not Be Alphanumeric or Backslash and Preg_Match
How to Change From-address When Using Gmail Smtp Server
I Have 2 Dates in PHP, How to Run a Foreach Loop to Go Through All of Those Days
How to Escape Strings in SQL Server Using PHP
PHP File_Get_Contents() Returns "Failed to Open Stream: Http Request Failed!"
How to Implement Authorization Using a Telegram API
Convert a Series of Parent-Child Relationships into a Hierarchical Tree