Jump to content

[Q] IsLink Function


Recommended Posts

i want to control a text that is entered to input.if the text is a link <f.e: www.autoitscript.com or autoitscript.com>, the function will return 1.

How can i do it?

i try it but methinks its only for "lnk" files.

$oshell = ObjCreate("shell.application")

if $oshell.NameSpace("autoitscript.com").isLink = True then

Link to comment
Share on other sites

Hi,

i use some functions which (or is it where?) may help you

Func _extracturl($sURL) ;ersten teil der url holen, um das icon auf der page zu finden
    Local $a = StringRegExp($sURL, '^(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~/|/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))', 3)
    If @error = 0 Then Return $a[0]
    MsgBox(0, 0, $sURL & "   ist keine url")
EndFunc   ;==>_extracturl

Func _isurl($sURL) ;test ob string im url-Format vorliegt, regex hier gefunden:  http://geekswithblogs.net/casualjim/archive/2005/12/01/61722.aspx
    $a = StringRegExp($sURL, "^(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~/|/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(?:(?:(?:/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|/)+|\?|#)?(?#Query)(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?#Anchor)(?:#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?{:content:}quot;, 3)
    If @error = 0 Then Return 1 ;url ist im korrekten Format
    If $sURL <> "" Then MsgBox(262144 + 64, "Information", "Ihre angegebene URL: " & @CRLF & $sURL & @CRLF & "entspricht nicht dem URL-Format!" & @CRLF & "Bitte ändern sie die URL!")
    Return 0
EndFunc   ;==>_isurl

Func _domain_from_url($url) ;gibt ein www.xxxx.de von http://www.xxxx.de/test/test2 zurück
    Local $t = StringRegExp(_extracturl($url), "(?:\w+:\w+@)?(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))", 3)
    Return $t[0]
EndFunc   ;==>_domain_from_url
Edited by AndyG
Link to comment
Share on other sites

Func _isurl($sURL)
    $a = StringRegExp($sURL, "^(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~/|/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(?:(?:(?:/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|/)+|\?|#)?(?#Query)(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?#Anchor)(?:#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?$", 3)
    If @error = 0 Then
        SetError(1)
        if stringleft($sURL,7) <> "http://" or stringleft($sURL,4) <> "www." then
            Return "www."&$sURL
        EndIf
        Return $sURL
    EndIf
    SetError(0)
    Return 0
EndFunc

Edited by blackman12
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...