1<script type="text/javascript">
2function youtube_parser(url){
3 var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/;
4 var match = url.match(regExp);
5 return (match&&match[7].length==11)? match[7] : false;
6}
7</script>
8
9These are the types of URLs supported
10
11http://www.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index
12http://www.youtube.com/user/IngridMichaelsonVEVO#p/a/u/1/QdK8U-VIH_o
13http://www.youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0
14http://www.youtube.com/watch?v=0zM3nApSvMg#t=0m10s
15http://www.youtube.com/embed/0zM3nApSvMg?rel=0
16http://www.youtube.com/watch?v=0zM3nApSvMg
17http://youtu.be/0zM3nApSvMg
1// true when ID is found, false otherwise.
2//Extracts youtube ID
3<script type="text/javascript">
4function youtube_parser(url){
5 var regExp = /^https?\:\/\/(?:www\.youtube(?:\-nocookie)?\.com\/|m\.youtube\.com\/|youtube\.com\/)?(?:ytscreeningroom\?vi?=|youtu\.be\/|vi?\/|user\/.+\/u\/\w{1,2}\/|embed\/|watch\?(?:.*\&)?vi?=|\&vi?=|\?(?:.*\&)?vi?=)([^#\&\?\n\/<>"']*)/i;
6 var match = url.match(regExp);
7 return (match && match[1].length==11)? match[1] : false;
8}
9</script>