
February 15th, 2012, 04:08 PM
|
|
Registered User
|
|
Join Date: Mar 2007
Posts: 15
Time spent in forums: 7 h 9 m 21 sec
Reputation Power: 0
|
|
|
need help with a regex expression to get youtube video id
I've got this URL for example
www.youtube.com/watch?v=NXtp7y24SHk&feature=g-all-u&context=G2dcd8bbF
I need help selecting the bolded part above and remove the rest.
I've got this code right now:
URL.replace(/(?:http:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)(?:.*v=)(.+)\s/g, '<iframe width="360" height="250" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>');
The problem is, it replaces everything before
NXtp7y24SHk&feature=g-all-u&context=G2dcd8bbF
and stops when it sees a space.
but how can i make it remove "&feature=g-all-u&context=G2dcd8bbF" as well
thanks.
|