AuToItItAlIaNlOv3R Posted August 2, 2009 Posted August 2, 2009 (edited) Hello forum. I've a problem >_< . I would to capture a part of test in a link. This is an esample of this link : http://wwwRANDOMNUMBER.xxxxxxx.com/files/RANDOMNUMBERANDLETTERS/THISISTHEPARTOFLINKTHATIWOLUDTOCAPUTURE It is an esample http://www87.xxxxxx.com/files/dfgd5h6y5fhfvnjthgj4g6h4/autoitrulez I would to caputure the string "autoitrulez"...how i can do? Hello Edited August 2, 2009 by AuToItItAlIaNlOv3R
Info Posted August 2, 2009 Posted August 2, 2009 (edited) $String = "http://www87.xxxxxx.com/files/dfgd5h6y5fhfvnjthgj4g6h4/autoitrulez" $StringReplace = StringReplace($String,"http://www87.xxxxxx.com/files/dfgd5h6y5fhfvnjthgj4g6h4/","") MsgBox(64,"StringReplace",$StringReplace) Edited August 2, 2009 by Info
AuToItItAlIaNlOv3R Posted August 2, 2009 Author Posted August 2, 2009 @Info The link generated random letters and number... This scritp work only for the my esample.
Tvern Posted August 2, 2009 Posted August 2, 2009 @Info The link generated random letters and number... This scritp work only for the my esample. $Pattern = "http://www[0-9]{0,}.xxxxxx.com/files/[a-z 0-9]+/" Dim $String[7] $String[0] = "http://www87.xxxxxx.com/files/dfgd5h6y5fhfvnjthgj4g6h4/autoitrulez" $String[1] = "http://www3456.xxxxxx.com/files/snfg89n76dfa90ga/autoitrulez" $String[2] = "http://www.xxxxxx.com/files/j09l3sdfg8d0fgd95a867sdf/autoitrulez" $String[3] = "http://www1.xxxxxx.com/files/q9we8r76gf09dn809bmv/autoitrulez" $String[4] = "http://www67856.xxxxxx.com/files/qwe0r87hf08n0g96e89r7t6/autoitrulez" $String[5] = "http://www7567.xxxxxx.com/files/yui9876zv09er0987sg/autoitrulez" $String[6] = "http://www456.xxxxxx.com/files/wqe987n9876sg8970bs6fd87gs9d/autoitrulez" For $i = 0 To 6 $Result = StringRegExpReplace($String[$i],$Pattern,"") MsgBox(0,"test",$Result) Next As you can see the same pattern will work on all strings that match the format you specified. The information on how to create patterns is in the helpfile for StringRegExp(). For instance if the random numbers and letters part can contain capital letters, you could change the pattern to: $Pattern = "http://www[0-9]{0,}.xxxxxx.com/files/[A-Z a-z 0-9]+/"
nekkutta Posted August 2, 2009 Posted August 2, 2009 $capture = StringTrimLeft($string, StringInStr($string,'/',0,-1)) [size="2"] "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian Kernighan[/size]
Tvern Posted August 2, 2009 Posted August 2, 2009 $capture = StringTrimLeft($string, StringInStr($string,'/',0,-1)) Hmm I didn't thing about being able to rely on the text to capture always being after the final "/". Your solution is probably more suitable for the case.
AuToItItAlIaNlOv3R Posted August 2, 2009 Author Posted August 2, 2009 Thank's a lot, the nekkutta solution is simple and functional! Now i've another problem >_< #include <GUIConstants.au3> #include <Ie.au3> #include <INet.au3> $Form1 = GUICreate("Form1", 259, 163, 339, 160) $navigator = ObjCreate("Shell.Explorer.2") GUICtrlCreateObj($navigator, 0, 0, 257, 161) GUISetState(@SW_SHOW) $pagesource = _INetGetSource ("http:www.xxxxxxxxx.com") $pagenavigate =_IENavigate ($navigator,$pagesource) I've this code, $pagesource creates the link for downloading a file, and $pagenavigate allows me to download it. Now i would to suggest to the user the file name to save, how i do it ? For esample i woult to suggest to the user the name of the file that i've grabb with nekkuta code : $capture = StringTrimLeft($string, StringInStr($string,'/',0,-1)) How i do it? thanks for the help!
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