I have a css file and inside it I have
url('PTN77F-webfont.eot') – for font name
and
@import url("layout.css"); as import.
I need to add some text before "PTN77F-webfont.eot" with preg_replace and other text before "layout.css". This are just examples, it can be any text there.
Basically I need to add some text inside the url('abc') and another text inside @import url("def").
What I did so far is:
$new_file_content = preg_replace("/([^import]\s*\burl\s*\('|\")(.*)('|\"\))/i", '$1'.JURI::base().'$2$3', $new_file_content);
which is working fine for url('PTN77F-webfont.eot') but my variable is added inside the @import url("layout.css") also, which is no good.
Looking forward for your help.
Well for the first one you can use the limit parameter of preg_replace.