In our one project we are appending css background image url with certain path in php that does not starts with 'http', 'website' or 'vendor', so far our expression is doing good but it is also including starting quote in result. Any help is appriciated
here is my php code
$array=[
'url("images")',
'url (\'images\')',
'url(vendor/)',
'url(website/)',
"url(http://)"
];
$pattern = '/url\s*\(\s*[\'"]?\/?([^(http|vendor|website)].+?)[\'"]?\s*\)/i';
$result=[];
foreach ($array as $test_string) {
$content = preg_replace($pattern, 'url('.'websites/abc/www/'.'$1)', $test_string);
$result[$test_string] = $content;
}
var_dump($result);
and the result is as follows, note that quote at www/"images
array (size=5)
'url("images")' => string 'url(websites/abc/www/"images)' (length=29)
'url ('images')' => string 'url(websites/abc/www/'images)' (length=29)
'url(vendor/)' => string 'url(vendor/)' (length=12)
'url(website/)' => string 'url(website/)' (length=13)
'url(http://)' => string 'url(http://)' (length=12)
Any help is appreciated, thank you in advanced.
url\s*\(\s*[\'"]?+\/?+((?!http|vendor|website).+?)[\'"]?\s*\)