I am converting the eregi_replace function that I found for preg_replace, but the eregi line has just about every character on the keyboard. So I tried to use £ as a delimiter .. and it works now, but I wonder if this could potentially cause problems because it is a non-standard character?
Here is the eregi:
function makeLinks($text) {
$text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'<a href="\\1">\\1</a>', $text);
$text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'\\1<a href="http://\\2">\\2</a>', $text);
return $text;}
and preg:
function makeLinks($text) {
$text = preg_replace('£(((f|ht){1}tp://)[-a-zA-^Z0-9@:%_\+.~#?&//=]+)£i',
'<a href="\\1">\\1</a>', $text);
$text = preg_replace('£([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)£i',
'\\1<a href="http://\\2">\\2</a>', $text);
return $text;
}
Damon source
share