parsing - Get Youtube Video ID From Link With JavaScript -
is there way video id youtube link.
i have way in php script, need in javascript.
here php script
function get_youtube($url){ parse_str( parse_url( $url, php_url_query ), $my_array_of_vars ); return $my_array_of_vars['v']; }
for example have youtube video link
http://www.youtube.com/watch?v=fwnar-rxaic&list=rd029i9ar6upx34
then content of v variable = fwnar-rxaic
the below function return video id of video if valid youtube url or return false.
function matchyoutubeurl(url){ var p = /^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\s+)?$/; return (url.match(p)) ? regexp.$1 : false ; }
Comments
Post a Comment