How do I find all YouTube video ids in a string using a regex?

A YouTube video URL may be encountered in a variety of formats: latest short format: http://youtu.be/NLqAF9hrVbY iframe: http://www.youtube.com/embed/NLqAF9hrVbY iframe (secure): https://www.youtube.com/embed/NLqAF9hrVbY object param: http://www.youtube.com/v/NLqAF9hrVbY?fs=1&hl=en_US object embed: http://www.youtube.com/v/NLqAF9hrVbY?fs=1&hl=en_US watch: http://www.youtube.com/watch?v=NLqAF9hrVbY users: http://www.youtube.com/user/Scobleizer#p/u/1/1p3vcRhsYGo ytscreeningroom: http://www.youtube.com/ytscreeningroom?v=NRHVzbJVx8I any/thing/goes!: http://www.youtube.com/sandalsResorts#p/c/54B8C800269D7C1B/2/PPS-8DMrAn4 any/subdomain/too: http://gdata.youtube.com/feeds/api/videos/NLqAF9hrVbY more params: http://www.youtube.com/watch?v=spDj54kf-vY&feature=g-vrec query may have dot: http://www.youtube.com/watch?v=spDj54kf-vY&feature=youtu.be nocookie domain: http://www.youtube-nocookie.com Here is a PHP function with a … Read more