Jump to content

Recommended Posts

Posted (edited)

To make it a single input you need to decide whether the URL request will be something with a page part like:

http://www.google.com/search?q=AutoIt

or anything is allowed, for example:

www.google.com
1.2.3.4.5
this is not a url path at all
etc..

Take a loop for example on this:

Dim $aURL[10] = ["http://www.google.com/search?q=hello", _
                "yahoo.com/join?q=now&b=never", _
                "gov.principle.com/outlaw?name=all", _
                "http://www.www.w ww/loop/www?ww=w", _
                "https://12.145.67.55/", _
                "www.autoitscript.com", _
                "https://www.w3c.com", _
                "221.90.176.5/", _
                "Not URL string", _
                "Nither"]

Dim $sPatt = "^((?:(?:https?|ftp|file)://)?[\w\d]+(?:\.[\w\d]+)+)/(.+)"
UBound()
For $i = 0 To 9
    $aMatch = StringRegExp($aURL[$i], $sPatt, 1)
    If IsArray($aMatch) Then
        ConsoleWrite($i & '-> Host: ' & $aMatch[0] & ', Page: ' & $aMatch[1] & @CRLF)
    EndIf
Next

If you'll change the last part of the regular expression pattern to (?:(.+))? you allow to strings without the page part to return as positive.

Edited by Authenticity

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...