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

From: Date: Tue, 21 Jan 2003 23:38:33 +0000
Subject: Fw: I need my PHP script to call a TCL proc
Groups: php.general 
Request: Send a blank email to php-general+get-132519@lists.php.net to get a copy of this message
----- Original Message ----- From: <posting-system@google.com> To: <soazine@erols.com> Sent: Tuesday, January 21, 2003 5:36 PM Subject: I need my PHP script to call a TCL proc > From: soazine@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@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 "\\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

« previous php.general (#132519) next »