Youtube I.D parsing for new URL formats

前端 未结 5 1823
借酒劲吻你
借酒劲吻你 2020-12-02 12:18

This question has been asked before and I found this:

Reg exp for youtube link

but I\'m looking for something slightly different.

I need to match th

5条回答
  •  悲&欢浪女
    2020-12-02 13:17

    It's a bit late, but I wrote this regex today and it does not only identify the links but returns the video_id via match-group 6

    ^(https?\:\/\/)?(www\.)?(youtube\.com|youtu\.?be)(\/)?(watch\?v=|\?v=)?(.*)$
    

    https://gist.github.com/Shibizle/3c6707911ea716860786728d31f8e3e5

    Test it: https://regex101.com/r/l0m7yh/1

    Picture: Regex YouTube

提交回复
热议问题