php-general | 2001072
Date: 07/31/01
- Next message: Kyle Smith: "Re: [PHP] Attitude of B van Ouwerkerk"
- Previous message: Jeff Lewis: "RE: [PHP] Attitude of B van Ouwerkerk"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Kyle Smith: "Re: [PHP] Attitude of B van Ouwerkerk"
- Previous message: Jeff Lewis: "RE: [PHP] Attitude of B van Ouwerkerk"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

