Sort of yes....
I thought it can be done with the /e modifier!

Can't it be done with pure RegExps?

"* R&Ze:" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> <Original message>
> From: _lallous <[EMAIL PROTECTED]>
> Date: Wed, Sep 05, 2001 at 12:17:21PM +0200
> Message-ID: <[EMAIL PROTECTED]>
> Subject: [PHP] For the RegExps gurus!
>
> > I want to write a RegExp that converts something like this:
> > $mem = "
> > Hello world! http://www.helloworld.com\n
> > Hello world! ftp://ftp.server.com\n
> > Hello world www.helloworld.com"
> >
> > how can I write a single regexp that converts $mem to this:
> > $mem = "
> > Hello world! <a
> > href="http://www.helloworld.com";>http://www.helloworld.com</a>\n
> > Hello world! <a href="ftp://ftp.server.com";>ftp://ftp.server.com</a>\n
> > Hello world <a
> > href="http://www.helloworld.com";>http://www.helloworld.com</a>"
> >
> > As you noticed that the second line didn't have the protocol specifier
and
> > it took by default "http://"; and the ones that had a protocol specifier
were
> > kept as is.
>
> </Original message>
>
> <Reply>
>
> This should do the job:
>
> --- PHP code ---
> <PRE>
> <?php
>
> $mem = "Hello world! http://www.helloworld.com\n
> Hello world! ftp://ftp.server.com\n
> Hello world www.helloworld.com";
>
> /* ------ ! Here's your regexp ! ------ */
> $mem = preg_replace ("/\s+([http:|ftp:]{0,1}\S+\.\S+)/me", "' <A href=\"'.
>         (ereg('^[http:|ftp:]','\\1')
>                 ? '\\1\">\\1</A>'
>                 : 'http://\\1\";>http://\\1</A>')", $mem);
>
> print ($mem);
>
> ?>
> </PRE>
> --- End of PHP code ---
>
> Let me know if this was what you were looking for...
>
> </Reply>
>
> --
>
> * R&zE:
>
>
> -- »»»»»»»»»»»»»»»»»»»»»»»»
> -- Renze Munnik
> -- DataLink BV
> --
> -- E: [EMAIL PROTECTED]
> -- W: +31 23 5326162
> -- F: +31 23 5322144
> -- M: +31 6 21811143
> --
> -- Stationsplein 82
> -- 2011 LM  HAARLEM
> -- Netherlands
> --
> -- http://www.datalink.nl
> -- ««««««««««««««««««««««««



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