tags:

views:

36

answers:

1

Is there a regex to get youtube video links or ids from embedded youtube videos on webpages?

+1  A: 

To find:
"<object(.*)youtube.com/v/(.*)\"(.*)</object>"

To convert to a link:
replace("<object(.*)youtube.com/v/(.*)\"(.*)</object>", '<a href="http://www.youtube.com/watch?v=\\2"&gt;click here</a>', $str)

source

BenV