php regex get first youtube id form text -


how get:

wa4nndfq0wa

form 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 html inside $html variable.

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

if change .*? .*(greedy) match last id.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -