The problem is that it matches the first foo with the first /foo and the
second foo witht eh /foo ( andmatches those properly) but it also matches
the first foo with the second /foo (thisnk of the logic of the regex).
What you need to do is rather than specify any character (.*) specify any
character which is not <foo> ie something like ^[<foo>]*

 On Wed, 9 May
2001, Luiz Vitor wrote:

> Hi...
>
> I have a text and, some words of the text have the tags <url></url> between them.
> What i'm trying to do is to replace the word between that tags for a url, wich I'll 
>search them in a database and convert to a url.
>
> It's working fine when I have only one <url></url>, but when there are more than 
>one, the script converts all the text between the first <foo></foo> and the last 
><foo></foo>.
>
> I'm using this code:
>
> if (eregi("<foo>(.*)</foo>", $string, $result)) {
>    $string = str_replace($result[1], '<a href="'.$result[1].'">'.$result[1].'</a>', 
>$string);
> }
>
>
> Someone knows what I have to do to put it to work???
>
>
> Thanks in advance.
>
> Luiz Vitor
> Brazil
>


-- 
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