Code: Select all
$src_regex = array('#(\s(href|src)=["|\'])(\./|/)?[^http://]?#i');
$src_replace = array('<font color="red">$1'.$url.'/</font>');
$line = '<pre>
img src="
img SRC=\'test.gif\'>
img src="/image.gif">
img src="./image.gif">
img src="http://www.example.org/image/image.gif">
img source="test"
a href="
a href=\'
a href="/image.gif">
a href="./image.gif">
a href="http://www.example.org/image/image.gif">
</pre>
';
echo preg_replace($src_regex, $src_replace, $line);
(the ' in the regex is escaped but doesn't show here for some reason)