Regex for youtube URL

后端 未结 8 1402
囚心锁ツ
囚心锁ツ 2020-11-28 09:12

I am using the following regex for validating youtube video share url\'s.

var valid = /^(http\\:\\/\\/)?(youtube\\.com|youtu\\.be)+$/;
alert         


        
8条回答
  •  天涯浪人
    2020-11-28 09:46

    Based on so many other regex; this is the best I have got:

    ((http(s)?:\/\/)?)(www\.)?((youtube\.com\/)|(youtu.be\/))[\S]+
    

    Test: http://regexr.com/3bga2

提交回复
热议问题