Try using the perl regular expressions and setting the quantifier to
ungreedy
e.g. This should work.
$pat = "/<url>(.*)<\/url>/U";
$rep = "<A HREF='\\1'>\\1</A>";
$string = preg_replace($pat, $rep, $string);
-Stewart
-----Original Message-----
From: Luiz Vitor [mailto:[EMAIL PROTECTED]]
Sent: 09 May 2001 15:14
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Search a string between <foo></foo>
It's still not working.
I'm using the pattern ([^<foo>]*) and I'm getting the first match correct,
but it's not getting all the other matches.
Thanks,
Luiz Vitor
----- Original Message -----
> From: "Toby Dacre" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, May 09, 2001 9:06 AM
> Subject: Re: [PHP] Search a string between <foo></foo>
>
>
> .* in your patten will match everything It's greedy like perl (unless
you
> compiled php not to be)
>
> add a ? and it will make it none greedy
>
> ^[<foo>]* will not work ^ needs to be in [] to mean not else it means
> start of string
>
>
> > ""Luiz Vitor"" <[EMAIL PROTECTED]> wrote in message
> > 011201c0d87d$57f8ab00$[EMAIL PROTECTED]">news:011201c0d87d$57f8ab00$[EMAIL PROTECTED]...
> > 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]
> >
> >
> >
>
--
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]
--
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]