$re = '`<iframe\s?(?:width="(?:\d+)?")?\s?(?:height="(?:\d+)?")?\s*(.*src="https://www\.(?:youtube|vimeo)\.com.*)</iframe>`m';
$str = '<iframe width="1228" height="691" src="https://www.youtube.com/embed/FBtUTYFYaG4" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';
$subst = "<div class=\"videoWrapper\"><iframe $1</iframe></div>";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
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