note 66507 added to function.preg-replace

From: Date: Wed, 24 May 2006 17:58:30 +0000
Subject: note 66507 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-111952@lists.php.net to get a copy of this message
Updated version of the link script, since the other version didn't work with links in beginning of line, links without http:// and emails. Oh, and a bf2:// detection too for all you gamers ;) function make_links_blank($text) { return preg_replace( array( '/(?(?=<a[^>]*>.+<\/a>) (?:<a[^>]*>.+<\/a>) | ([^="\']?)((?:https?|ftp|bf2|):\/\/[^<> \n\r]+) )/iex', '/<a([^>]*)target="?[^"\']+"?/i', '/<a([^>]+)>/i', '/(^|\s)(www.[^<> \n\r]+)/iex', '/(([_A-Za-z0-9-]+)(\\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-]+) (\\.[A-Za-z0-9-]+)*)/iex' ), array( "stripslashes((strlen('\\2')>0?'\\1<a href=\"\\2\">\\2</a>\\3':'\\0'))", '<a\\1', '<a\\1 target="_blank">', "stripslashes((strlen('\\2')>0?'\\1<a href=\"http://\\2\">\\2</a>\\3':'\\0'))", "stripslashes((strlen('\\2')>0?'<a href=\"mailto:\\0\">\\0</a>':'\\0'))" ), $text ); } ---- Server IP: 194.239.128.50 Probable Submitter: 212.242.230.37 ---- X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HTML_MESSAGE autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- http://master.php.net/note/edit/66507 Del: integrated -- http://master.php.net/note/delete/66507/integrated Del: useless -- http://master.php.net/note/delete/66507/useless Del: bad code -- http://master.php.net/note/delete/66507/bad+code Del: spam -- http://master.php.net/note/delete/66507/spam Del: non-english -- http://master.php.net/note/delete/66507/non-english Del: in docs -- http://master.php.net/note/delete/66507/in+docs Del: other reasons-- http://master.php.net/note/delete/66507 Reject -- http://master.php.net/note/reject/66507 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#111952) next »