Q:

In this case which is better in matching regular expression or parse_url

Suppose we have the following link
$link = "http://www.mysite.com/bbbbbbb.flv?something";

And we want to matching it.
Upon this question how to match links that has extension @Thanks to all@
We have two ways regular expression and parse_url
So my question which is better in your point of view and for my website (such as fast better accurate ..etc)?
Method 1 regular expression
if (preg_match('/\.flv(\?|$)/i', $link)) {
    echo 'It has flv';
} else {
    echo 'It does not have';
}

Method 2 parse_url
$arr = parse_url($link);

$pathParts = pathinfo($arr['path']);

if ($pathParts['extension'] == 'flv')
   echo "valid extension";
else
   echo "invalid extension";

@ Thanks

A:

According to this publication, using the built in parse_url is much slower than preg_match. This is understandably the case, because the regular expression captures a single result, whereas parse_url captures and parses all components of the url.

