-- Filen ---- showtext.asp:
<%
filnavn = "data.txt"
strText = ""
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTextStream = objFSO.OpenTextFile(Server.MapPath(filnavn), 1)
if Not objTextStream.AtEndOfStream then
strText = objTextStream.readAll
end if
objTextStream.Close
if strText <> "" then
'Lav links og email om til rigtige links
strText = LinkString (strText)
'Lav Enter-knappem om til HTML-return <br>.
strText = Replace(strText,vbCrLf,"<br>")
end if
'Udskrive teksten fra filen
Response.write strText
Set objTextStream = Nothing
Set objFSO = Nothing
'Functioner----------------------
Function LinkString(strInput)
Set objRegExpHTTP1 = New RegExp
Set objRegExpHTTP2 = New RegExp
Set objRegExpEMail = New RegExp
objRegExpHTTP1.Pattern = "(http|ftp)(:\/\/[\w\._-]+\.[\w\._-]+\S*)"
objRegExpHTTP2.Pattern = "(^|[^\/])(www[^\.\s]?\.[\w\._-]+\.[A-Za-z]{2,3}[\w\S]*)"
objRegExpEMail.Pattern = "([\w\._-]+@[\w\._-]+\.[A-Za-z]{2,3}\S*)"
objRegExpHTTP1.Global = True
objRegExpHTTP2.Global = True
objRegExpEMail.Global = True
objRegExpHTTP1.IgnoreCase = True
objRegExpHTTP2.IgnoreCase = True
objRegExpEMail.IgnoreCase = True
strOutput = objRegExpEMail.Replace(strInput, " <a href='mailto:$1'>$1</a> ")
strOutput = objRegExpHTTP1.Replace(strOutput, " <a href='$1$2' target='_blank'>$1$2</a> ")
strOutput = objRegExpHTTP2.Replace(strOutput, " $1<a href='
http://$2' target='_blank'>$2</a> ")
objRegExpHTTP2.Pattern = "(<br>|[,.)\]\}])('>)"
strOutput = objRegExpHTTP2.Replace(strOutput, "$2")
objRegExpHTTP2.Pattern = "(<br>|[,.)\]\}])(' target=)"
strOutput = objRegExpHTTP2.Replace(strOutput, "$2")
objRegExpHTTP2.Pattern = "(<br>|[,.)\]\}])(</a>)"
strOutput = objRegExpHTTP2.Replace(strOutput, "$2$1")
Set objRegExpHTTP2 = Nothing
set objRegExpHTTP1 = Nothing
Set objRegExpEMail = Nothing
LinkString = strOutput
End Function
%>