$re = '/(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|playlist\?|watch\?v=|watch\?.+(?:&|&);v=))([a-zA-Z0-9\-_]{11})?(?:(?:\?|&|&)index=((?:\d){1,3}))?(?:(?:\?|&|&)?list=([a-zA-Z\-_0-9]{34}))?(?:\S+)?/';
$str = 'https://www.youtube.com/playlist?list=PL1eC1aP-LYNg2ya1ywPj0pipd0y2EWGEl
https://www.youtube.com/watch?v=4UcfECYbDYQ&index=1&list=PL1eC1aP-LYNg2ya1ywPj0pipd0y2EWGEl
https://youtu.be/4UcfECYbDYQ?list=PL1eC1aP-LYNg2ya1ywPj0pipd0y2EWGEl
https://www.youtube.com/watch?v=Svmor6ouuO4&index=4&list=PL1eC1aP-LYNg2ya1ywPj0pipd0y2EWGEl
https://www.youtube.com/watch?v=M44e92KoIaE
https://youtu.be/M44e92KoIaE
https://www.youtube.com/embed/videoseries?list=PL1eC1aP-LYNg2ya1ywPj0pipd0y2EWGEl';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php