hjælp jeg er dum !!
Hej har en access db som jeg henter noget text ud af, og som dum som jeg er vil jeg gerne have at hvis folk skriver http://palle.dk, og andre lign. ting, at det så bliver konverteret til et link :-) Det ville jeg så ordne med noget kode som jeg har fundet på nettet og det følger her :<%
Option Explicit
Const MyQUOT = """"
Const MySPACE = " "
Const LINK_START = "<a href="
Const LINK_END = "</a>"
Const DEFAULT_PROTOCOL = "http"
Function autoHighlight(Text)
Dim Dummy
Dim objRegExp, objMatch, objMatches
Dim objFoundLinks, objFoundLinksLocations
Set objRegExp = New RegExp
objRegExp.IgnoreCase = True
objRegExp.Global = True
Set objFoundLinks = Server.CreateObject("Scripting.Dictionary")
Set objFoundLinksLocations = Server.CreateObject("Scripting.Dictionary")
Text = MySPACE & Text & MySPACE
objRegExp.Pattern = "\w+\@\w+\.\w+"
Set objMatches = objRegExp.Execute(Text)
For Each objMatch In objMatches
If objFoundLinksLocations.Exists(objMatch.FirstIndex) Then
'Kan ikke bruges...
Else
objFoundLinks.Add objMatch, "email"
objFoundLinksLocations.Add objMatch.FirstIndex, "email"
End If
Next
objRegExp.Pattern = "([A-Za-z]{2,5}\:\/\/)*\d\d?\d?\.\d\d?\d?\.\d\d?\d?\.\d?\d?\d?(\/+[\w\?\&\%\.]*)*"
Set objMatches = objRegExp.Execute(Text)
For Each objMatch In objMatches
If objFoundLinksLocations.Exists(objMatch.FirstIndex) Then
'Kan ikke bruges
Else
objFoundLinks.Add objMatch, "ip"
objFoundLinksLocations.Add objMatch.FirstIndex, "ip"
End If
Next
objRegExp.Pattern = "(\s|([A-Za-z]{2,5}\:\/\/))(\w+\.+\w{2,}\:*)+[\/+[\w\?\&\%\.\=]*]*\s"
Set objMatches = objRegExp.Execute(Text)
For Each objMatch In objMatches
If objFoundLinksLocations.Exists(objMatch.FirstIndex) Then
'kan ikke bruges
Else
objFoundLinks.Add objMatch, "server"
objFoundLinksLocations.Add objMatch.FirstIndex, "inet"
End If
Next
For Each objMatch In objFoundLinks.Keys
If (InStr(1, objMatch.Value, "://") > 0) Or (InStr(1, objMatch.Value, "@") > 0) Then
Text = Left(Text, objMatch.FirstIndex) & LINK_START & MyQUOT & Trim(objMatch.Value) & MyQUOT & ">" & TRIM(objMatch.Value) & LINK_END & Mid(Text, objMatch.FirstIndex + Len(objMatch.Value))
' autoHighlight = autoHighlight & " " & LINK_START & MyQUOT & Trim(objMatch.Value) & MyQUOT & ">" & Trim(objMatch.Value) & LINK_END & " - " & objFoundLinks.Item(objMatch) & " - " & objMatch.FirstIndex & "<br>"
Else
Text = Left(Text, objMatch.FirstIndex) & LINK_START & MyQUOT & DEFAULT_PROTOCOL & ":// " & Trim(objMatch.Value) & MyQUOT & ">" & Trim(objMatch.Value) & LINK_END & Mid(Text, objMatch.FirstIndex + Len(objMatch.Value))
'Mid(Text, objMatch.FirstIndex, Len(objMatch.Value)) =
' autoHighlight = autoHighlight & " " & LINK_START & MyQUOT & DEFAULT_PROTOCOL & ":// " & Trim(objMatch.Value) & MyQUOT & ">" & Trim(objMatch.Value) & LINK_END & " - " & objFoundLinks.Item(objMatch) & " - " & objMatch.FirstIndex & "<br>"
End IF
Next
autoHighlight = Text
End Function
%>
Og det så og fint ud og hvis jeg kører det eks, som følger med virker det også fint http://62.243.91.224/test/temp
men når jeg så kalder filen for functions.asp og includer den ligesom eksemplet gør, får jeg bare en dum 500 fejl.
jeg kalder det som følger :
<%=autoHighlight(Replace(Server.HTMLEncode(List("context")),vbCrLf,"<br>"))%> og hvis jeg fjerne autoHighlight virker det fint. Har også prøvet at fylde context i en variable men det hjalp heller ikke.
