Re: For the RegExps gurus!
| From: | _lallous | Date: | Thu, 06 Sep 2001 12:29:17 +0000 |
| Subject: | Re: For the RegExps gurus! | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-66202@lists.php.net to get a copy of this message | ||
The reason I don't want to use the /e switch is that i'll be able to port
that expression to perl or to javascript.
"* R&Ze:" <renze@datalink.nl> wrote in message
news:20010906122808.N19403@pro-pain.telemediair.nl...
> And another option...
>
> --- PHP code ---
> <PRE>
> <?php
>
> $mem = "Hello world! http://www.helloworld.com\n
> Hello world! ftp://ftp.server.com\n
> Hello world www.helloworld.com";
>
> /* ------ ! First regexp ! ------ */
> // $mem = preg_replace ("/\s+([http:|ftp:]{0,1}\S+\.\S+J,Ϳº
> ÕÏ×s7
›8)/me", "' <A
> // href=\"'.
> // (ereg('^[http:|ftp:]','\\1')
> // ? '\\1\">\\1</A>'
> // :
> 'http://\\1\">http://\\1</A>')", $mem);
>
> /* ------ ! Second regexp ! ------ */
> // $repl = array ("" => "http://",
> // "http://" =>
> "http://",
> // "ftp://" =>
> "ftp://");
> // $mem = preg_replace
> ("/\s+([http:|ftp:]*(\/\/)*)(\S+\.\S+)/me",
> // "' <A
> //
> href=\"'.\$repl['\\1'].'\\3\">'.\$repl['\\1'].'\\3</A>'",
> // $mem);
>
> /* ------ ! Third regexp ! ------ */
> $mem = preg_replace
> ("/\s+([http:|ftp:]*(\/\/)*)(\S+\.\S+)/me",
> "' <A href=\"'.('\\1' ? '\\1' :
> \"http://\").'\\3\">'.
> ('\\1' ? '\\1' : \"
>http://\").'\\3</A>'",
> $mem);
>
> print ($mem);
>
> ?>
> </PRE>
> --- End of PHP code ---
>
> ...and ...keep on trying...
>
> --
>
> * R&zE:
>
>
> -- »»»»»»»»»»»»»»»»»»»»»»»»
> -- Renze Munnik
> -- DataLink BV
> --
> -- E: renze@datalink.nl
> -- W: +31 23 5326162
> -- F: +31 23 5322144
> -- M: +31 6 21811143
> --
> -- Stationsplein 82
> -- 2011 LM HAARLEM
> -- Netherlands
> --
> -- http://www.datalink.nl
> -- ««««««««««««««««««««««««