php3-list | 2000051
Date: 05/01/00
- Next message: charette <email protected>: "Re: [PHP3] about php+apache+orace"
- Previous message: TomHenry: "Re: [PHP3] PHP Code - Win v. *nix"
- In reply to: Nicholas Pappas: "[PHP3] Multiple RegExp replace"
- Next in thread: Nicholas Pappas: "Re: [PHP3] Multiple RegExp replace"
- Reply: Nicholas Pappas: "Re: [PHP3] Multiple RegExp replace"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
* Nicholas Pappas <nick <email protected>> [000501 08:34] wrote:
> Hello all!
>
> I am trying to write up a little parser that will go through and
> replace multiple occurances of variable (ie: it changes) string in a large
> message block.
> Specifically, it looks for "http://[a-z.]*" and putts a HREF
> tag around it, so that it is linked without typing the HREF in manually.
>
> Here is what I have right now:
>
> <?php
> $string = "This is a string with a http://link.com and a
> http://second.com";
>
> eregi("(http://[a-z.]*)", $string, $regs);
>
> $newstr = eregi_replace("(http://[a-z.]*)", "<A
> HREF=\"$regs[1]\">$regs[1]</A>", $string);
>
> echo $string
> ?>
>
> The obvious trouble with this is that it links all the hyperlinks
> to "http://link.com" (the first matched expression).
>
> I am wondering how (if possible) I can set this up to replace all
> the links properly.
> Is there a running variable (like '$_' in PERL) that I can use?
something like this:
$string = eregi_replace("(http://[a-z.]*)",
"<A HREF=\"\\0\">\\0</A>", $string);
if \\0 doesn't work, use \\1
-Alfred
-- PHP 3 Mailing List <http://www.php.net/> To unsubscribe, send an empty message to php3-unsubscribe <email protected> To subscribe to the digest, e-mail: php3-digest-subscribe <email protected> To search the mailing list archive, go to: http://www.php.net/mailsearch.php3 To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: charette <email protected>: "Re: [PHP3] about php+apache+orace"
- Previous message: TomHenry: "Re: [PHP3] PHP Code - Win v. *nix"
- In reply to: Nicholas Pappas: "[PHP3] Multiple RegExp replace"
- Next in thread: Nicholas Pappas: "Re: [PHP3] Multiple RegExp replace"
- Reply: Nicholas Pappas: "Re: [PHP3] Multiple RegExp replace"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

