I am trying to find a regex to convert relative url in css code 'url()'. So far this is what I have:
$domain = "http://example.com/";
$html = "url(1.css), url(' 1.css'), url( \"1.css\")";
$rep['/url(\s*)\((\s*)"(\s*)(?!https?:\/\/)(?!data:)(?!#)/i'] = 'url("'.$domain;
$rep["/url(\s*)\((\s*)'(\s*)(?!https?:\/\/)(?!data:)(?!#)/i"] = "url('".$domain;
$html = preg_replace(
array_keys($rep),
array_values($rep),
$html
);
echo $html;
Current Output:
url(1.css), url('http://example.com/1.css'), url("http://example.com/1.css")
Desired Output:
url(http://example.com/1.css), url('http://example.com/1.css'), url("http://example.com/1.css")
$rep['/url(\s*)\((\s*)["\']?(\s*)(?!https?:\/\/)(?!data:)(?!#)/i'] = 'url("'.$domain;