Negative Assertions help...
Posted: Sun Mar 02, 2008 8:34 pm
Basically what I want to do is add a url before any image tags that don't already have a url in front of them... So for example, this:
Would be replaced with this:
Here is my code... it works when the image tag already has a url before the image source but doesn't apply the domain to images that don't...
Any ideas how I can fix my code to make this work?
Code: Select all
<img src="images/logo.jpg" border="0" />Code: Select all
<img src="http://www.domain.com/images/logo.jpg" border="0" />Code: Select all
$websiteurl = 'http://www.domain.com';
$content = preg_replace('#src="([^"]+?!http://|!https://)#im', "src=\"".$websiteurl."/$1", $content);