youtube preg_replace pattern
$youtube_pattern1 = "/\s*[a-zA-Z\/\/:\.]*youtube.com\/watch\?v=([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i";
$youtube_pattern2 = "/\s*[a-zA-Z\/\/:\.]*youtu.be\/([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i";
$youtube_pattern3 = '/(?:https?:\/\/)?(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=)?([\w-]{10,})/m';
$str = preg_replace($youtube_pattern3, '<div><iframe style="width:100%;min-height:190px;" src="https://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe><br /><a class="autolink"" href="https://www.youtube.com/watch?v=$1\">https://www.youtube.com/watch?v=$1</a></div>', " ".$str);