I think you would be much better off using a function dedicated to the purpose, rather than a custom regular expression.
Since the example you provided is actually a URL, you could use the parse_url function:
http://php.net/manual/en/function.parse-url.php
You should also look at the pathinfo (well done PHP on the naming consistency there!):
http://php.net/manual/en/function.pathinfo.php
You could then do something like this:
$url = 'http://localhost/path/file.php';
$url_info = parse_url($url);
$full_path = $url_info['path'];
$path_info = pathinfo($full_path);
$file_name = $path_info['filename'] . '.' . $path_info['extension'];
print $file_name; // outputs "file.php"
This might seem more verbose than using regular expressions, but it likely to be much faster and, more importantly, much more robust.