Reputation: 522
In my code I am trying to extract url only from my string using preg_match() function but its not working properly I tried all possible references but nothing works for me.
Here is the string example
FileID = "http://downloader.example.com/myfile/Josh.mp4";
My Expectation
http://downloader.example.com/myfile/Josh.mp4
Here is my php code
<?php
$stringURL = "FileID = \"http://downloader.example.com/myfile/Josh.mp4\";";
preg_match('/FileID(.*)=(.*)"(.*)"/U', $stringURL,$matches);
if (isset($matches[0])) {
$myurl = $matches[0];
} else {
$myurl = "http://";
}
echo $myurl;
?>
Upvotes: 1
Views: 62
Reputation: 19327
Why not it like this?
preg_match('/https?\:\/\/[^\" ]+/i', $stringURL,$matches);
Upvotes: 1