Hi,

I'm trying to figure out a regex that would match substrings in
a string that are NOT inside tags. In the example below I try
to replace the substring 'paris' with
<a href=\"http://www.somehost.com";>paris</a> but it also matches
'paris' in the image name.

* this does not work:
$url = "http://www.somehost.com";;
$needle = "paris";
$haystack = "<img src=\"/images/3_im_paris_tower.jpg\"> paris trip";
$regex="($needle).*?[^>]";
echo preg_replace ("/$regex/", "<a href=\"$url\">\\1</a> ",$haystack);

An even simpler example of what I am trying to do is as follows:
Match 'a' in the following string if it is followed by
( zero or more of *any* character, then NOT a '>' )

* this does not work ( using regex ASSERTIONS )
* it matches the 'a' before the '>' ... which I don't want )
$haystack = "ad>bc|abc ";
$regex="(a(?=.*?)(?!>))";

Thanks in advance for your help,
Bruce


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to