This documentation is archived and is not being maintained.

Example: Extracting URL Information

The following code example uses Match.Result to extract a protocol and port number from a URL. For example, "" would return "http:8080".

    Function Extension(url As String) As String
        Dim r As New Regex("^(?<proto>\w+)://[^/]+?(?<port>:\d+)?/", _
        Return r.Match(url).Result("${proto}${port}")
    End Function
    String Extension(String url) 
        Regex r = new Regex(@"^(?<proto>\w+)://[^/]+?(?<port>:\d+)?/",
        return r.Match(url).Result("${proto}${port}"); 

See Also

.NET Framework Regular Expressions