Extract links inside embed tags in WordPress
No need to use regex. WordPress has a handy function to strip shortcodes from a string. Use strip_shortcodes( $content ). So in your case, $content = “”; $your_clean _url = strip_shortcodes( $content ); echo $your_clean_url; // should output https://www.youtube.com/watch?v=Z9QbYZh1YXY EDIT Here’s a function (tested) that will remove your “unwanted” shortcode, and any other one. function … Read more