' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.Text.RegularExpressions

Class MainClass
    Public Shared Sub Main(ByVal args As String())
        Console.WriteLine(FirstPart("http://www.eksperten.dk/spg124/infoting/lala/"))
        Console.WriteLine(Domain("http://www.eksperten.dk/spg124/infoting/lala/"))
        Console.WriteLine(NoWww("http://www.eksperten.dk/spg124/infoting/lala/"))
    End Sub

    Public Shared Function FirstPart(ByVal s As String) As String
        FirstPart = Regex.Matches(s, "(http://www.[^/]*/)")(0).Groups(1).Value
    End Function

    Public Shared Function Domain(ByVal s As String) As String
        Domain = Regex.Matches(s, "(?:http://www.)([^/]*)")(0).Groups(1).Value
    End Function

    Public Shared Function NoWww(ByVal s As String) As String
        Dim m As Match = Regex.Matches(s, "(http://)(?:www.)([^/]*/)")(0)
        NoWWW = m.Groups(1).Value & m.Groups(2).Value
    End Function
End Class 
