我正在尝试搜索像这样的JW Player嵌入代码:
<iframe src="//content.jwplatform.com/players/ewQYJ6zA-F6KYzWLn.html" width="480" height="270" frameborder="0" scrolling="auto" allowfullscreen></iframe>
我需要抓取的是players/
之后的代码,此嵌入中的代码只是ewQYJ6zA
。
任何人都知道如何解决这个问题?
答案 0 :(得分:2)
答案 1 :(得分:2)
这将搜索玩家/后跟一个或多个字母和数字。
<?php
$string = '<iframe src="//content.jwplatform.com/players/ewQYJ6zA-F6KYzWLn.html" width="480" height="270" frameborder="0" scrolling="auto" allowfullscreen></iframe>';
preg_match( '~/players/([[a-zA-Z\d]+)~', $string, $matches );
echo $matches[1];
?>
<强>输出强>: ewQYJ6zA