note 46491 added to function.preg-replace

From: Date: Wed, 13 Oct 2004 07:58:49 +0000
Subject: note 46491 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-78472@lists.php.net to get a copy of this message
just my 2cent tips for auto-linking url in text - without "href=" defined!, if you need, modify it. - it should work for any type url , modify it for specific protocol. - just remove " //WRAPPED// ", so its became one line more 2cent tips at http://sysadmin.eu.org/?blog_cat=code <?php $result = preg_replace("/((http|ftp)+(s)?:(\/\/)([\w]+(.[\w]+)) //WRAPPED// ([\w\-\.,@?^=%&:;\/~\+#]*[\w\-\@?^=%&:;\/~\+#])?)/i", "<a href=\"\\0\">\\0</a>", $text); ?> ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46491 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46491&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46491&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46491&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46491&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46491&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46491&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+46491&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#78472) next »