Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/09/2014, 14:51
Max_4
 
Fecha de Ingreso: mayo-2013
Ubicación: Guadalajara
Mensajes: 53
Antigüedad: 10 años, 11 meses
Puntos: 0
Equivalente de ereg_replace a preg_replace

function toLink($text)
{
$text = html_entity_decode($text);
$text = " ".$text;
$text = ereg_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)','<a href="\1" target="_blank" >\1</a>', $text);
$text = ereg_replace('(((f|ht){1}tps://)[-a-zA-Z0-9@:%_+.~#?&//=]+)','<a href="\1" target="_blank" >\1</a>', $text);
$text = ereg_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)','\1<a href="http://\2" target="_blank">\2</a>', $text);
$text = ereg_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})','<a href="mailto:\1" target="_blank">\1</a>', $text);
return $text;
}

Tengo esta funcion pero php me dice que ereg replace es obsoleta, y al usar preg_replace no me acepta los patrones, que modificaciones deberia tener para que preg_replace la acepte?

Saludos. Gracias.