0

Looks that I have some error in my script.

preg_replace does not work in this example:

This is an example that I use as $message:

<div class="videoss videoss1PUT2a5NafI"><a href="#" class="videoshow" id="1PUT2a5NafI"><div style="background:url(/i/play.png) center no-repeat,url(https://img.youtube.com/vi/1PUT2a5NafI/mqdefault.jpg) center no-repeat;background-size:30%,cover;" class="pd39 mroim60"><div class="captn"></div></div></a></div>

I need the script to return:

https://www.youtube.com/watch?v=1PUT2a5NafI

from this example. This is my preg_replace:

$message = preg_replace("@\<div class=\"videoss videoss(.*?)\"><a href=\"#\" class=\"videoshow\" id=\"(.*?)\"><div style=\"background:url(/i/play.png) center no-repeat,url(https://img.youtube.com/vi/(.*?)/mqdefault.jpg) center no-repeat;background-size:30%,cover;\" class=\"pd39 mroim60\"><div class=\"captn\"></div></div></a></div>@si", "https://www.youtube.com/watch?v=\\1", $message);

Unfortunately, i does not replace anything and returns $message as it is.

Verode
  • 145
  • 2
  • 9

0 Answers0