Forum Documentation Showcase Pricing Learn more

Working with full youtube-link

Hi,

I’m trying to let my users upload a link to their youtube video and display it on their profiles. But I have to use the video-ID, which they often get that wrong.

I suppose I could extract the ID with RegEx, but it seems there must be an easier way?

The optimal solution would be if they could just input a full link.

Any ideas?

the Video.js plugin accepts youtube links if that suits your projects needs.

Regex is the way example

^.*(youtu.be\/|v\/|embed\/|watch\?|youtube.com\/user\/[^#]*#([^\/]*?\/)*)\??v?=?([^#\&\?]*).*

I limit the number of characters on the input to 11, people usually figure it out since they can’t paste the full url