Ver Mensaje Individual
  #11 (permalink)  
Antiguo 27/09/2009, 13:36
Jhon Silver
 
Fecha de Ingreso: marzo-2004
Ubicación: Madrid (España)
Mensajes: 837
Antigüedad: 21 años, 1 mes
Puntos: 9
De acuerdo Respuesta: Convertir texto plano a enlaces activos

Cita:
Iniciado por Adler Ver Mensaje
Hola

Aquí te dejo un ejemplo. Es mejorable, pero es lo que se me ha ocurrido al vuelo

Código asp:
Ver original
  1. <&#37;
  2. Function LimpiarHref(texto)
  3. Dim objRegExp
  4.  
  5.     Set objRegExp= New RegExp
  6. objRegExp.IgnoreCase = True
  7. objRegExp.Global = True
  8.  
  9. objRegExp.Pattern = "(<a[^>]+href\s?=\s?""?)(ht(t)p\:\/\/www\.(?!misitio))([^<]*)("">)([^>]*)([<])(/)*([\w])([>])"
  10. texto = objRegExp.Replace(texto, "<em><span style=""font-size:9px;"">VINCULO ELIMINADO</span></em>")
  11.  
  12. Gracias Adler
  13.  
  14.     Set objRegExp = Nothing
  15.  
  16.     LimpiarHref = texto
  17.  
  18. End Function
  19.  
  20. Response.Write LimpiarHref("Veamos que vinculos apuntan hacia mi web. Este parece que sí <a href=""http://www.misitio/prueba/prueba1"">http://www.misitio/prueba/prueba1</a>, este otro.... no! así que <a href=""http://www.otrositio/prueba2"">http://www.otrositio/prueba2</a>. Aquí tenemos otro, veamos <a href=""http://www.misitio/prueba"">http://www.misitio/prueba3</a> pues sí, es un vinculo interno. <br/>Parece que viene otro <a href=""http://www.otrositio/prueba/prueba4"">http://www.otrositio/prueba/prueba4</a> por que puede ser spam")
  21. %>

Suerte
Muchas gracias Adler