In PHP, what are the advantages and disadvantages of using GET parameters versus regex for extracting URLs from a string?

When extracting URLs from a string in PHP, using GET parameters can be advantageous as it provides a simple and straightforward way to access and parse the URL components. However, using regex for extracting URLs offers more flexibility and control over the extraction process, allowing for more complex pattern matching. The choice between the two methods depends on the specific requirements of the task at hand.

// Using GET parameters to extract URLs from a string
$url = $_GET['url'];

// Using regex to extract URLs from a string
$string = "This is a sample text with a URL https://www.example.com and another URL http://www.test.com";

preg_match_all('/(https?|ftp):\/\/[^\s\/$.?#].[^\s]*/', $string, $matches);

foreach ($matches[0] as $url) {
    echo $url . "\n";
}