views:

253

answers:

1

If a few of you are unfamiliar with Wordpress's YouTub tag, it looks like this

[youtube=http://www.youtube.com/watch?v=ooCLnrmIRFo&feature=related]

I am not very good with regular expressions, and all I have found out how to do is get from everything in between "[youtube=" and "]" using the following, but i need the value of "v".

(\[youtube=)(.+)(\])

Your help is much appreciated.

+1  A: 
\[youtube=http://[^\]]+v=([\w-]+)[^\]]*\]

However, it would be better to just extract the URL and then use some validation on it, and finally pass it to parse_url and parse_str($url['query'], $blah) => $blah['v'] will have the v param then.

KiNgMaR
I like your suggestion and your regex... now i am torn ;)
Jeremy