Hello,
I want to save url of youtube video into my database and later show on my website. Currently I have form where I’m able to save in DB but I have two problems/questions.
How can I save only this v=7r7r_qU8Eow for example and not whole URL. My point is that I can’t force users to extract just this ‘v=7r7r_qU8Eow’ from whole URL. And if user enter this - “https://www.youtube.com/watch?v=7r7r_qU8Eow” in DB must save only ‘v=7r7r_qU8Eow’.
How exactly to retrieve from DB video and show on website?
I have tryed with embeded code but no success. I’ve tryed like this:
To alter my previous post, you could use a Regular Expression to go along with this Regular Expression:
var link = 'https://www.youtube.com/watch?v=hv_X327YUdI&list=SPGznEl712WelO6ZhS8lc2ssweLuQaCKld';
var reg = new RegExp("[&?]list=([a-z0-9_]+)","i");
It’s abridged but you get the idea. If you want to use both approaches it’s cool. Or, you could just use a regex for both of them to keep your code clean. It’s an OCD thing