blackman12 Posted July 14, 2010 Posted July 14, 2010 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
blackman12 Posted July 15, 2010 Author Posted July 15, 2010 $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 1endifi can do with these codes.but this process takes several time.how can i find a shorter route?
AndyG Posted July 15, 2010 Posted July 15, 2010 (edited) Hi, i use some functions which (or is it where?) may help youFunc _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 July 15, 2010 by AndyG
blackman12 Posted July 15, 2010 Author Posted July 15, 2010 this (_isurl) function is more valid than the other ones. Thanks thanks again thanks AndyG
blackman12 Posted July 15, 2010 Author Posted July 15, 2010 (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 July 15, 2010 by blackman12
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now