build youtube url from id code example
Example: get youtube video id from url javascript
// true when ID is found, false otherwise.
//Extracts youtube ID
<script type="text/javascript">
function youtube_parser(url){
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;
var match = url.match(regExp);
return (match && match[1].length==11)? match[1] : false;
}
</script>