preg_replace question
| From: | Jean-Christian IMbeault | Date: | Sat, 16 Aug 2003 13:08:39 +0000 |
| Subject: | preg_replace question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-159794@lists.php.net to get a copy of this message | ||
I found this nice preg_replace function that replaces all occurrences of an HTML anchor (<a href=...) with a link to another PHP script that log the link and then sends the user on his merry way to the the appropriate page/site:
preg_replace(
"#<a href=(\"|')http://([^\"']+)(\"|')#ime",
'"<a href=\"/exit.php?url=".base64_encode(\'\\2\')."\""',
$originalLink
);
I'd like to modify this expression so that it does the same thing but *only* if the link is not to a specific page. I.e. I would like to replace all links *unless* the link was to, for example, www.mydomain.com.
How can I achieve this with a regexp? I'm not very good at 'negative' regexp ...
Thanks,
Jean-Christian Imbeault