getting the youtube id from a link

前端 未结 9 1180
清歌不尽
清歌不尽 2020-12-24 13:09

I got this code to get the youtube id from the links like www.youtube.com/watch?v=xxxxxxx

  URL youtubeURL = new URL(link);
  youtubeURL.getQuery();
         


        
9条回答
  •  佛祖请我去吃肉
    2020-12-24 13:35

    That pattern worked for me:

    "http(?:s?)://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)([\w\-]+)(&(amp;)?[\w\?=‌​]*)?"
    

    source: Regular expression for youtube links

提交回复
热议问题