note 79311 added to function.preg-replace

From: Date: Tue, 20 Nov 2007 13:06:43 +0000
Subject: note 79311 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-132433@lists.php.net to get a copy of this message
$text = preg_replace("/[^<> ]([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6} [a-zA-Z0-9\/\*\-\?\&\%\=]*)([^\s|\.|\,<])/i", '<a href="$0" target="_blank">$0</a>',$text); $text = preg_replace("/(\s)(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6} [a-zA-Z0-9\/\*\-\?\&\%\=]*)/i", '$1<a href="http://$2" target="_blank">$2</a>',$text); Your example didn't work... This is what i've changed and now works fine NOTE: also remove whitespaces (enter, space) from expression, if any ---- Server IP: 69.147.83.197 Probable Submitter: 89.137.97.220 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- https://master.php.net/note/edit/79311 Del: integrated -- https://master.php.net/note/delete/79311/integrated Del: useless -- https://master.php.net/note/delete/79311/useless Del: bad code -- https://master.php.net/note/delete/79311/bad+code Del: spam -- https://master.php.net/note/delete/79311/spam Del: non-english -- https://master.php.net/note/delete/79311/non-english Del: in docs -- https://master.php.net/note/delete/79311/in+docs Del: other reasons-- https://master.php.net/note/delete/79311 Reject -- https://master.php.net/note/reject/79311 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132433) next »