hello I want to replace this code of css:
background:url("/media/image.png")
and I have a url
$url3 ="http://example.com";
here is the code I'm using :
preg_replace('~url\(("|\')?/?(.*?)(?:\1)?\)~', 'url($1'.$url3.'/$2$1)', background:url("/media/image.png");
the output of this code gives me :
background:url("http://example.com/media/image.png")
and this is what I want , but my problem is I want to add some conditions to my regex for example if the url have //
or http
or https
at start then ignore it don't add http://example.com/ to it.
this is the regex I have tried :
~url\(("|\')?/?(.*?)(?:\1)?\)~(((?!'|\"|http://|https://|//).)*)(['\"])-i
but it didn't work ..