str_replace ile bu olamaz anca regex ile yapabilirsiniz. Aşağıdaki kod çalışması ve çıktı olarak linki vermesi gerekli.

$var = preg_replace_callback('/<figure\s*class="media">\s*<oembed\s*url="(https:\/\/www\.(?:instagram.com)\/p\/[a-zA-Z0-9_-]+)\/"><\/oembed>\s*<\/figure>/', function($matches) {
    return $matches[1];
}, $text);