php regex获取第一个youtube id表单文本

how to get:

WA4nNDfQ0wA

form this code:

<p>some text here ...</p>
<iframe width="640" height="360" src="//www.youtube.com/embed/WA4nNDfQ0wA?feature=player_embedded" frameborder="0" allowfullscreen></iframe>
<div>some text here ...</div>
<iframe width="640" height="360" src="//www.youtube.com/embed/9gypDWA6r2s?feature=player_embedded" frameborder="0" allowfullscreen></iframe>

by using php?

Assuming your html is inside the $html variable.

preg_match("|.*?/embed/([\w-]+)|", $html, $m);
print $m[1];

If you change the .*? into .*(greedy) then it will match the last id.