I want to get the v=id
from YouTube’s URL with JavaScript (no jQuery, pure JavaScript). get YouTube video id from Link with PHP Regex
Example YouTube URL formats
http://www.youtube.com/watch?v=hw_HpTI_Wkw&a=GxdCwVVULXctT2lYDEPllDR0LRTutYfW
http://www.youtube.com/watch?v=hw_HpTI_Wkw
Or any other YouTube format that contains a video ID in the URL.
Result from these formats
hw_HpTI_Wkw
How to get youtube video id from url – javascript
<script type="text/javascript">
function youtube_parser(url){
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/;
var match = url.match(regExp);
return (match&&match[7].length==11)? match[7] : false;
}
</script>
If you want to get ID value from URL of YouTube video through java script then you can use
How to get YouTube video id from url with PHP Regex
Do you also want to get the value of ID of any video through YouTube Video URL, then you can try the code given below.
<?php
$strq = $_POST['q'];
preg_match('/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/', $strq, $matches);
echo '<pre>';
print_r($matches);
echo '</pre>';
echo $matches[7];
?>
By using this code you will get watch?v= Value of Video
Tag:-
how to get youtube video id from url javascript
how to get video id from youtube url php
get video id from youtube url python
how to get video id from youtube url in android
get youtube video id from url flutter
youtube video id length
youtube api get video id from url
extract youtube link