 <p>try this</p> <pre><code>preg_replace('@(?&lt;!http:)//.*@','',$test); </code></pre> <p>also read more about PCRE assertions <a href="http://cz.php.net/manual/en/regexp.reference.assertions.php" rel="nofollow">http://cz.php.net/manual/en/regexp.reference.assertions.php</a></p>