Regexp to extract sources from different video embeds
Posted
by Ben
on Stack Overflow
See other posts from Stack Overflow
or by Ben
Published on 2010-05-09T02:03:17Z
Indexed on
2010/05/09
2:08 UTC
Read the original article
Hit count: 320
My SMF forum contains posts with video and I want to extract them to show on the Wordpress main page. My current regexp (thanks to SO!) extracts the url of the videos, which I embed using AutoEmbed.
Everything works up until a post looks like this:
<embed height="600" width="600" allowscriptaccess="never" quality="high" loop="true" play="true" src="http://mmavlog.net/embed/player.swf?file=http://video.ufc.tv/CSG/UFC113/20100507_ufc113_weigh_in_400k.flv" type="application/x-shockwave-flash">
Here is my current regexp:
$regexp = "/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i";
Since the posts can contain <embed>
or <object>
I realize that looking for the url by the "http" might be inaccurate. How can I use the regexp to look for "src=" for <embed>
and "data=" for <object>
?
© Stack Overflow or respective owner