note 57741 deleted from function.preg-replace by tularis

From: Date: Sun, 18 Jun 2006 13:28:17 +0000
Subject: note 57741 deleted from function.preg-replace by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-114319@lists.php.net to get a copy of this message
Note Submitter: Nick Bullock - SafireX ---- An improved and corrected version of a function I put together to process HTML strings from a database or output buffer. <? function linkScan($string1) { $pattern1 = "/(?<![\\/\\d\\w])(http:\\/\\/)?([\\w\\d\\-]+) ((\\.([\\w\\d\\-])+){2,})([\\/\\?\\w\\d\\.\\-_&=+%]*)?/i"; $replace1 = "<a href=\\"http://$2$3$6\\" target=\\"popup\\">$0</a>"; $string2 = preg_replace($pattern1,$replace1,$string1); $pattern2 = "/[\\d\\w\\.\\-_]+@[\\d\\w\\-_\\.]+? \\.[\\w]{2,3}(\\.[\\w]{2,3})?/i"; $replace2 = "<a href=\\"mailto:$0\\">$0</a>"; $string3 = preg_replace($pattern2,$replace2,$string2); return $string3; } ?>

« previous php.notes (#114319) next »