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 remove_unwanted_shortcode($shortcode, $content) {
    $start = "[" . $shortcode . "]";
    $stop = "[/" . $shortcode . "]";

    $cleanFirst = str_ireplace($start, '', $content);
    $cleanSecond = str_ireplace($stop, '', $cleanFirst);

    return $cleanSecond;
}

And you would use it like so:

$content = "";
$short = "embed";
echo remove_unwanted_shortcode($shortcode, $content);