----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 21, 2003 5:36 PM
Subject: I need my PHP script to call a TCL proc
> From: [EMAIL PROTECTED] (Phil Powell)
> Newsgroups: comp.lang.tcl,comp.lang.php
> Subject: I need my PHP script to call a TCL proc
> NNTP-Posting-Host: 65.201.150.91
> Message-ID: <[EMAIL PROTECTED]>
>
> It's either that my PHP script call a working TCL proc that converts
> all string text that looks like a URL ("http://...") into a hyperlink,
> or does someone have a PHP equivalent to do it? My PHP function
> VALIDATE_URL fails to do any conversion in its regexp, however, the
> TCL proc works every time, and the matching pattern is nearly
> identical in both!
>
> TCL:
>
> proc VALIDATE_URL {contents} {
> regsub -all "\\n" $contents "<br>" contents
> regsub -all {\.{2,}} $contents {. .} contents
> regsub -all
{(http://([a-zA-Z0-9_\-]+\.)+(/[a-zA-Z0-9_\-\.\~\^,%\+]+)*[^<\(\)>
> ]+)} $contents "<a href=\\1 target=_new><font
> style='text-decoration:none'>\\1</font></a>" contents
> regsub -all {\. \.} $contents {..} contents
> return $contents
> }
>
> PHP:
>
> function VALIDATE_URL($contents) {
> $contents = preg_replace("/\\n/e", '<br>', $contents);
> $contents = preg_replace('/\.{2,}/e', '. .', $contents);
> $contents =
preg_replace('/http[s]?:\/\/\([a-zA-Z0-9_\-]+\.\)+\(\/[a-zA-Z0-9_\-\.\~\^,%\
+]+\)*[^<\\(\\)>
> ]+\)/ei', "<a href=\\\\1 target=_new>\\\\1</a>", $contents);
> return preg_replace('/\. \./e', '..', $contents);
> }
>
> So who wins, TCL or PHP?
>
> Thanx
> Phil
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php