Extract links inside embed square brackets in WordPress

I am using the default WordPress embed to embed a couple of videos in the content.

I want to extract the video link from [embed]https://www.youtube.com/watch?v=Z9QbYZh1YXY[/embed], can anyone help with the regex?

I have been busy with a similar problem today using PHP…

  1. $tmp = file_get_contents(‘remote_url’);
  2. $tmp = strstr ($tmp, ‘https://www.youtube.com/watch?v=’); // to extract trailing script
  3. $tmp = substr ($tmp, 32, 43); // check these paraketers

Typing on a tablet and source code is on the desktop.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.