在锚点html中匹配一个url

时间:2016-06-08 18:01:53

标签: php regex

我想在锚点html中匹配一个url并返回url。子域和路径文件总是在变化。

这是网址。

https://regex101.com/r/gB4bB8/3

我希望它仅返回网址https://s04.solidfilesusercontent.com/NGU0MGIwZTg1MDU0MjI5YzE3YzM3NDQ4ZWJhNjVhN2Y3ZGVmN2EwNDoxYkFmRkY6ODZvb29qRG8tdFluMXl2TU1hR1dBN19ockt3/v8grz2RpkMkWd/As_The_Gods_Will_%282014%29-1.mp4

到目前为止,这是我的代码

$matches = "";

$regex = '/<a.+?href=("|\')(.+?)\1/i';

$url = "<a target='blank' href='https://s04.solidfilesusercontent.com/NGU0MGIwZTg1MDU0MjI5YzE3YzM3NDQ4ZWJhNjVhN2Y3ZGVmN2EwNDoxYkFmRkY6ODZvb29qRG8tdFluMXl2TU1hR1dBN19ockt3/v8grz2RpkMkWd/As_The_Gods_Will_%282014%29-1.mp4'>https://s04.solidfilesusercontent.com/NGU0MGIwZTg1MDU0MjI5YzE3YzM3NDQ4ZWJhNjVhN2Y3ZGVmN2EwNDoxYkFmRkY6ODZvb29qRG8tdFluMXl2TU1hR1dBN19ockt3/v8grz2RpkMkWd/As_The_Gods_Will_%282014%29-1.mp4</a>";

preg_match($regex, $url, $matches);

echo $matches[0];

THX

0 个答案:

没有答案