Foros del Web » Programando para Internet » ASP Clásico »

ayuda con funcion cortar links

Estas en el tema de ayuda con funcion cortar links en el foro de ASP Clásico en Foros del Web. gentess estoy intentando hacer una funcion que toma una cadena, y si tiene links los corta, la necesito para una pagina que administro ya que ...
  #1 (permalink)  
Antiguo 15/07/2008, 07:51
 
Fecha de Ingreso: junio-2008
Mensajes: 6
Antigüedad: 16 años
Puntos: 0
ayuda con funcion cortar links

gentess

estoy intentando hacer una funcion que toma una cadena, y si tiene links los corta, la necesito para una pagina que administro ya que al poner comentarios los usuarios pegan cadenas largas y me desencajan la pagina. El script es el siguiente

************************************************** ***************

<html>
<head>
<title>problema</title>
</head>
<body>
<%
dim strIn, strOut, strTemp, strURL, strClave
dim posIniUrl, posFinUrl, newCad
dim enlaceCorto
posIniUrl = 0
posFinUrl = 0
strTemp = ""
strIN = "Esta es la direccion www.intramed.net pero tenesmos tambien WWW.INTRAMED.NET en nuestra lista, probaremos a continuacion que tambien admita http://www.intramed.net como valido y por ultimo, nos falto probar que HTTP://WWW.INTRAMED.NET tambien cargara"
enlaceCorto = ""
do while (instr(1,strIN,"http.//",1)) or (instr(1,strIN,"www",1))
if instr(strIn,"www") then
strClave ="www"
elseif instr(strIn,"WWW") then
strClave ="WWW"
elseif instr(strIn,"http://") then
strClave ="http://"
else
strClave ="HTTP://"
end if
posIniUrl = instr(strIn,strClave)
strTemp = mid(strIn,1,(posIniUrl)-1)
strOut = mid(strIn,posIniUrl) & " "
posFinUrl = instr(strOut," ")
strURL = mid(strout,1,posFinUrl)
enlaceCorto = (mid(strUrl,1,20) & "...")
if strClave = "www" then
strtemp = strtemp & "<a href= http://" & strUrl & (chr34) & ">" & enlaceCorto & "</a>"
elseif strClave ="WWW" then
strtemp = strtemp & "<a href= http://" & strUrl & (chr34) & ">" & enlaceCorto & "</a>"
else
strtemp = strtemp & "<a href=" & strUrl & (chr34) & ">" & enlaceCorto & "</a>"
end if
strIn = mid(strOut,posfinurl)
newCad = newcad & strTemp
strClave = ""
strTemp = ""
loop
newCad = newcad & strIn
%>
<%
response.write newCad
%>
</body>
</html>
************************************************** ***************


agradeceria mucho me pudieran ayudar
  #2 (permalink)  
Antiguo 16/07/2008, 18:12
Avatar de Shiryu_Libra
Colaborador
 
Fecha de Ingreso: febrero-2007
Ubicación: Cantando "Screenager" en "Kirafa Kaput"
Mensajes: 3.614
Antigüedad: 17 años, 3 meses
Puntos: 88
Respuesta: ayuda con funcion cortar links

cortar cadenas de link.....

si empiezan con www o http

no seria mas sencillo, esto?
Cita:
<%
strIN = "Esta es la direccion www.intramed.net pero tenesmos tambien WWW.INTRAMED.NET en nuestra lista, probaremos a continuacion que tambien admita http://www.intramed.net como valido y por ultimo, nos falto probar que HTTP://WWW.INTRAMED.NET tambien cargara"
temp=split(strin," ")
for i=0 to ubound(temp)
select case lcase(left(temp(i),3))
case "www" temp(i)="*"
case "htt" temp(i)="*"
end select
cadena=cadena & " " & temp(i)
next
response.Write cadena
%>
solo tendrias que evaluar cuando un usuario en lugar de esas entradas, escribiera simplemente
forosdelweb.com ó maestrosdelweb.com
aunque... un right(strin,4) y evaluar que no termine con ".com" o ".mx" o todas sus variantes



edito:

algo asi mejor
Código:
<%
strIN = "Esta es la direccion www.intramed.net pero tenesmos tambien WWW.INTRAMED.NET en nuestra lista, probaremos a continuacion que tambien admita http://www.intramed.net intramed.net como valido y por ultimo, nos falto probar que HTTP://WWW.INTRAMED.NET tambien cargara intramed.gob"
response.Write strin &"<br /><br /><br />"
response.Flush()
temp=split(strin," ")
for i=0 to ubound(temp)
    select case lcase(left(temp(i),3))
        case "www" temp(i)="<a href= http://" & temp(i) & (chr34) & ">Link</a>"
        case "htt" temp(i)="<a href= http://" & temp(i) & (chr34) & ">Link</a>"
        case else 
            if instr(temp(i),".com") then temp(i)="<a href= http://" & temp(i) & (chr34) & ">Link</a>"
            if instr(temp(i),".net") then temp(i)="<a href= http://" & temp(i) & (chr34) & ">Link</a>"
            if instr(temp(i),".tv") then temp(i)="<a href= http://" & temp(i) & (chr34) & ">Link</a>"
            if instr(temp(i),".org") then temp(i)="<a href= http://" & temp(i) & (chr34) & ">Link</a>"
            if instr(temp(i),".gob") then temp(i)="<a href= http://" & temp(i) & (chr34) & ">Link</a>"
    end select
    cadena=cadena & " " & temp(i)
next
response.Write cadena
response.Flush()
%>
__________________
"Eres parte del problema, parte de la solucion o parte del paisaje"
Un Saludo desde Desierto de Altar, Sonora, MX.
Shiryu_libra

Última edición por Shiryu_Libra; 16/07/2008 a las 18:26
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:00.