NYCPHP Meetup

NYPHP.org

Fw: I need my PHP script to call a TCL proc

Phil Powell soazine at erols.com
Tue Jan 21 18:38:33 EST 2003


----- Original Message -----
From: <posting-system at google.com>
To: <soazine at erols.com>
Sent: Tuesday, January 21, 2003 5:36 PM
Subject: I need my PHP script to call a TCL proc


> From: soazine at erols.com (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: <1cdca2a7.0301211436.3950d68a at posting.google.com>
>
> 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 "\\\
" $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("/\\\
/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




More information about the talk mailing list