Remove Custom Divs from AMP pages

Thanks to Thomas’ answer to my question at StackOverflow – https://stackoverflow.com/questions/53158606/remove-div-with-a-class-without-removing-content

Here’s how you can do it on WordPress for AMP. In your theme’s functions.php add the following:-

add_action( 'pre_amp_render_post', 'amp_vid_rmv' );
   function amp_vid_rmv() {
add_filter( 'the_content', 'amp_vid_div_rmv' );
} 
function amp_vid_div_rmv($content) {
   $content = preg_replace('#<div class="yt">([\s\S]*?)</div>#', '$1', $content);
   return $content;
}

Please feel free to improve on this.