Private Function StripUrl(ByVal Input As String) As String Dim returnUrl As String Dim strUrl As String = Input If Not strUrl = "" Then Dim re As Regex = New Regex("^(?<uri>((http|https|ftp)://)?[^/]+/?)", RegexOptions.IgnoreCase) Dim Result As Match = re.Match(strUrl) If Result.Success Then strShortUrl = Result.Groups("uri").Value End If Else strShortUrl = "Der er ikke angivet nogen Url" End If
returnUrl = strShortUrl Return returnUrl End Function
Den bruger jeg, i en lidt længere udgave, til et statistik modul, hvor jeg skal bruge både den fulde og den afkortede url ;o)
Det var så lidt og du spørger bare hvis ikke det virker for dig ;o)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.