February 15th, 2012, 05:08 PM
need help with a regex expression to get youtube video id
I've got this URL for example
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
and stops when it sees a space.
but how can i make it remove "&feature=g-all-u&context=G2dcd8bbF" as well
February 15th, 2012, 06:00 PM
1. It's easier to match the bit you want than to remove the bits you don't want.
2. What language are you using?
February 15th, 2012, 09:40 PM
This will match the bold text in numerous regex flavors:
But as requinix was asking, what flavor / language are you using?