Page 1 of 1

bug in the regular expression

Posted: Tue Nov 23, 2004 6:28 pm
by jasongr
Hello people

I would like to use regular expression to check if a string contains the definition of background-image:url(<file>.png) attribute

that is in the following strings the attribute will be found:
style="background-image: url('test.png')"
style="background-image: url('/Folder/test.png')"
style="background-image: url('./folder/Test.png')"

I tried the following but it doesn't work:

Code: Select all

preg_match_all('/background-image:\s*url\(''(.*\.png)''\);/Uis',$s, $matches);
However count($matches[0]) is always zero

can anyone see what is wrong with the regular expression, or maybe something is wrong in my examples

thanks

Posted: Tue Nov 23, 2004 7:08 pm
by rehfeld
i see a semi colon in your pattern, but not in the examples

you could make it optional by putting a question mark after it eg
;?

also, for debugging, try print_r($matches);

that way you see everything it matched.

Posted: Wed Nov 24, 2004 2:37 am
by jasongr
thanks for the suggestion
I will implement it