how to check the valid Youtube url using jquery

后端 未结 8 760
心在旅途
心在旅途 2020-12-10 14:02

In Jquery i want to check the specific url from youtube alone and show success status and others i want to skip by stating it as not valid url

var _videoUrl          


        
8条回答
  •  旧时难觅i
    2020-12-10 14:21

    I found this from the closure library, might be handy:

    /**
     * A youtube regular expression matcher. It matches the VIDEOID of URLs like
     * http://www.youtube.com/watch?v=VIDEOID.
     * @type {RegExp}
     * @private
     */
    goog.ui.media.YoutubeModel.matcher_ =
        /https?:\/\/(?:[a-zA_Z]{2,3}.)?(?:youtube\.com\/watch\?)((?:[\w\d\-\_\=]+&(?:amp;)?)*v(?:<[A-Z]+>)?=([0-9a-zA-Z\-\_]+))/i;
    

提交回复
热议问题