Alan
Mon Aug 14 19:04:10 CDT 2006
Hi,
I just want to check the string is a valid format.
I don't need a too detail check but a more general one.
Besides these prefixes:
http://
www.
https://
And suffixes:
.htm
.html
What other I need to check?
"McKirahan" <News@McKirahan.com> wrote in message
news:Ga6dnbmZY_g0633ZnZ2dnUVZ_q6dnZ2d@comcast.com...
> "Alan T" <alanpltseNOSPAM@yahoo.com.au> wrote in message
> news:uGU2Cy2vGHA.3912@TK2MSFTNGP03.phx.gbl...
>> Hi,
>>
>> I would like to know is there a generic rule that I can follow to
> determine
>> if the string is a valid URL?
>> eg. prefix is http, www...etc.
>
> By valid do you mean does it exist or do you mean well formed?
>
> RFC 1738 will help you determine if a URL is well formed;
>
http://www.faqs.org/rfcs/rfc1738.html
>
> To test if a URL exists you could use XMLHTTP:
>
> Option Explicit
> Const cVBS = "ExistURL.vbs"
> Dim strURL
> strURL = InputBox("Enter a URL",cVBS)
> WScript.Echo strURL & " = " & Fetch(strURL)
>
> Function Fetch(URL)
> On Error Resume Next
> Err.Clear
> Dim objXML
> Set objXML = CreateObject("Microsoft.XMLHTTP")
> objXML.Open "GET",URL,False
> objXML.Send
> If Err.Number <> 0 Or objXML.Status <> 200 Then
> Fetch = False
> Exit Function
> End If
> Set objXML = Nothing
> Fetch = Err.Number = 0
> End Function
>
>
>