tags:

views:

184

answers:

1

Example URLs

http://www.youtube.com/user/Scobleizer#p/u/1/1p3vcRhsYGo
http://www.youtube.com/watch?v=cKZDdG9FTKY&feature=channel
http://www.youtube.com/watch?v=yZ-K7nCVnBI&playnext_from=TL&videos=osPknwzXEas&feature=sub
http://www.youtube.com/ytscreeningroom?v=NRHVzbJVx8I

Any regex that will pull the correct YID from all 4 of these use cases? The first case is especially odd.

Thank you.

+3  A: 
(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=[0-9]/)[^&\n]+|(?<=v=)[^&\n]+

This works. http://i.imgur.com/SQJW2.jpg

I use a program called RegexBuddy.

Daeyun
YES! Thank you so much!
novaurora
You're welcome!
Daeyun