Sign in to follow this  
Followers 0
blackman12

[Q] IsLink Function

5 posts in this topic

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

Share this post


Link to post
Share on other sites



$sText = "example"

if stringleft($stext,7) <> "http://" or stringleft($stext,4) <> "www." then

$sText = "http://www." & $sText

$nSize = InetGetSize($stext)

if $nSize = 0 then Return 1

endif

i can do with these codes.but this process takes several time.how can i find a shorter route?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

this (_isurl) function is more valid than the other ones. Thanks thanks again thanks AndyG :blink:

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0