If you mean a Decomposition of an URL adress ? here is an example in vbscript :
Option Explicit
Dim adress,result,Title
Title = "Decomposition of an URL"
'Some examples for testing
'adress = "http://www.laltruiste.com:8080/coursasp/sommaire.html#ancre"
'adress = "ftp://ftp.microsoft.com/softlib/index.txt"
'adress = "http://www.google.com"
adress = InputBox( "Please input the http or the https address.", " What makes up a Url ?",_
"http://www.laltruiste.com:8080/coursasp/sommaire.html#ancre")
result = Search(trim(adress))
MsgBox Title & " ( Uniform Resource Locator ) ==> URL : " & DblQuote(adress) & vbCrLf & vbCrLf & result,64,Title
'*******************************************************
Function Search(MyString)
Dim objet,correspondance,collection,pattern
pattern="^" & _
"(\w+):\/\/([^/:]+)" & _
"(:(\d+))?" & _
"(" & _
"\/" & _
"(" & _
"(" & _
"([^/]+)" & _
"\/" & _
")?" & _
"(" & _
"([^#]+)" & _
")?" & _
"(" & _
"(#(\w+)?)?" & _
")?" & _
")?" & _
")?" & _
"$"
Set objet = New RegExp
objet.Pattern = Pattern
objet.IgnoreCase = True
objet.Global = True
if objet.test(MyString) then
Set collection = objet.Execute(MyString)
Set correspondance = collection(0)
result = "Protocol = " & DblQuote(correspondance.SubMatches(0)) & VbCRLF & vbCrLf _
& "Domain = " & DblQuote(correspondance.SubMatches(1)) & VbCRLF & vbCrLf _
& "Port = " & DblQuote(correspondance.SubMatches(3)) & vbCrLf & vbCrLf _
& "Folder = " & DblQuote(correspondance.SubMatches(7)) & VbCRLF& vbCrLf _
& "File = " & DblQuote(correspondance.SubMatches(9)) & VbCRLF& vbCrLf _
& "Anchor = "& DblQuote(correspondance.SubMatches(12))
Search = result
else
Search = MsgBox("no match ===> no result found !",48,Title)
end if
End Function
'----------------------------------------------------------------
'Function to add double quotes into a variable
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'----------------------------------------------------------------
You can also use PowerShell to do this very easily.
$uri = "http://www.laltruiste.com:8080/coursasp/sommaire.html#ancre"
[system.uri]$uri
And you can get as result like that :
AbsolutePath : /coursasp/sommaire.html
AbsoluteUri : http://www.laltruiste.com:8080/coursasp/sommaire.html#ancre
LocalPath : /coursasp/sommaire.html
Authority : www.laltruiste.com:8080
HostNameType : Dns
IsDefaultPort : False
IsFile : False
IsLoopback : False
PathAndQuery : /coursasp/sommaire.html
Segments : {/, coursasp/, sommaire.html}
IsUnc : False
Host : www.laltruiste.com
Port : 8080
Query :
Fragment : #anchor
Scheme : http
OriginalString : http://www.laltruiste.com:8080/coursasp/sommaire.html#ancre
DnsSafeHost : www.laltruiste.com
IsAbsoluteUri : True
UserEscaped : False
UserInfo :