Hi
I want to make a decomposition of a URL
So I have this Vbscript below :
My problem is when I type eg URL = " ==> the script returns me an error in line N ° 18 "incorrect procedure or argument"
However, when I type this URL = " ==> then it works 5/5
So I'm looking how to get around this error ?
Thnak you !
I want to make a decomposition of a URL
So I have this Vbscript below :
My problem is when I type eg URL = " ==> the script returns me an error in line N ° 18 "incorrect procedure or argument"
However, when I type this URL = " ==> then it works 5/5
So I'm looking how to get around this error ?
Code:
Option Explicit
Dim adress,result,Title
'*****************************************************************
'Fonction pour ajouter des guillemets dans une variable
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'*****************************************************************
Function Search(Pattern,MyString)
Dim objet
Dim correspondance
Dim collection
Set objet = New RegExp
objet.Pattern = Pattern
objet.IgnoreCase = True
objet.Global = True
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(2)) & vbCrLf & vbCrLf _
& "Folder = " & DblQuote(correspondance.SubMatches(3)) & VbCRLF& vbCrLf _
& "File = " & DblQuote(correspondance.SubMatches(4)) & VbCRLF& vbCrLf _
& "Anchor = "& DblQuote(correspondance.SubMatches(5))
Search = result
End Function
'*****************************************************************
'adress = "[URL unfurl="true"]http://www.laltruiste.com:8080/coursasp/sommaire.html#ancre"[/URL]
adress = InputBox( "Please input the http or the https address.", " What makes up a Url?","[URL unfurl="true"]http://www.laltruiste.com:8080/coursasp/sommaire.html#ancre")[/URL]
result = Search("(\w+):\/\/([^/:]+):?(\d*)?\/(.*[^.])\/(\w+.\w+)#?(\w+)?",adress)
Title = "Decomposition of a URL address"
MsgBox Title & "(Uniform Resource Locator ) ==> URL : " & DblQuote(adress) & vbCrLf & vbCrLf _
& result,64,Title