regular expression funktion
HejsaJeg har tidligere brugt denne funktion i ASP, men nu vil jeg gerne have lavet den om til ASP.NET
Er der en der kan hjælpe mig med det?
Function FormatText(ByVal strInput)
strInput = Replace(strInput, "<BR>", vbCrLf)
' Konverter HTML-tags
' str = Server.HTMLEncode(str)
arrPattern = Array("([\w\._-]+@[\w\._-]+\.[A-Za-z]{2,4}\S*)", _
"(http|https|ftp)(:\/\/[\w\._-]+\.[\w\._-]+\S*)", _
"(^|[^\/])(www[^\.\s]?\.[\w\._-]+\.[A-Za-z]{2,4}\S*)")
arrReplaceString = Array(" <a href=""mailto:$1"" CLASS=""Link"">$1</a> ", _
" <a href=""$1$2"" target=""_blank"" CLASS=""Link"">$1$2</a> ", _
" <a href=""http://$2"" target=""_blank"" CLASS=""Link"">$2</a> ")
Rx = New RegExp()
Rx.Global = True
Rx.IgnoreCase = True
For intIndex = 0 To UBound(arrPattern)
Rx.Pattern = arrPattern(intIndex)
strInput = Rx.Replace(strInput, arrReplaceString(intIndex))
Next
Rx = Nothing
' Lav enkelt linieskift
strInput = Replace(strInput, vbcrlf, "<BR>")
FormatText = strInput
End Function
