zutto Posted May 25, 2009 Share Posted May 25, 2009 yeah.. didnt really get the help file [could be that i've been up for 43hours but thats not the point]i got string like:12452345438-641502-78459-214485-154643246and i am supposed to somehow detect that bolded area, those change..i tried withStringRegExp($sor, "{4}\-{6}\-{5}\-{6}\-{4}",1)StringRegExp($sor, "{4}-{6}-{5}-{6}-{4}",1)but i most likely just fail with those "{4}-{6}-{5}-{6}-{4}"someone could post up for me in right format or point me to right way Link to comment Share on other sites More sharing options...
Malkey Posted May 25, 2009 Share Posted May 25, 2009 yeah.. didnt really get the help file [could be that i've been up for 43hours but thats not the point] i got string like: 12452345438-641502-78459-214485-154643246 and i am supposed to somehow detect that bolded area, those change.. i tried with StringRegExp($sor, "{4}\-{6}\-{5}\-{6}\-{4}",1) StringRegExp($sor, "{4}-{6}-{5}-{6}-{4}",1) but i most likely just fail with those "{4}-{6}-{5}-{6}-{4}" someone could post up for me in right format or point me to right way This appears to work. ; Local $sString = '12452345438-641502-78459-214485-154643246' Local $sREResult = StringRegExpReplace($sString, ".*(\d{4}-\d{6}-\d{5}-\d{6}-\d{4}).*", "\1") MsgBox(0, "R E Result", $sREResult) ; Link to comment Share on other sites More sharing options...
GEOSoft Posted May 25, 2009 Share Posted May 25, 2009 what you have between the {} are quantifiers. You have to tell it what to quantify first. Your first{4] will fail because it doesn't know what it's looking for. next you tell it to look for 6 consecutive - then for 5 more consecutive - then for 6 more consecutive - and finally for 4 consecutive - For a grand total of 21 consecutive hyphens (same as -{21}) George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
kurtkafka Posted May 25, 2009 Share Posted May 25, 2009 (edited) Hello everybody,I'm using this thread, cause my problem is quite similar.I started programming in AutoIt a couple of weeks ago. It's the first programming I've done since the times with basic and my blessed C64.Thanks to the excellent helpfile and this forum here I get along quite nicely. But, a big but. ;-)Maybe I'm just small sighted or I'm just plain stupid, but I can't get behind how StringRegExp really works. I'm trying to receive a time from a website. I would like to have the data like this:$hours = 16$mins = 30$secs = 42The time is in the website like the following: xxxxxxxxxxxHTMLxxxxxxxxxx Time now : 16:30:42 xxxxxxxxxxxxxHTMLxxxxxxxxxxxxxxxI tried several times for the correct StringRegExp Expression, but nothing worked. I got so annoyed...Could you help me, please? Edited May 25, 2009 by kurtkafka Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 25, 2009 Moderators Share Posted May 25, 2009 Local $s_data = "xxxxxxxxxxxHTMLxxxxxxxxxx Time now : 16:30:42 xxxxxxxxxxxxxHTMLxxxxxxxxxxxxxxx"; Of course this will be your html Local $s_hour, $s_mins, $s_secs Local $a_sre = StringRegExp($s_data, "(?i)Time now : (\d+):(\d+):(\d+)", 1) If Not @error Then $s_hour = $a_sre[0] $s_mins = $a_sre[1] $s_secs = $a_sre[2] EndIf MsgBox(64, "Info", _ "Hour =" & @TAB & @TAB & $s_hour & @CRLF & _ "Minutes =" & @TAB & @TAB & $s_mins & @CRLF & _ "Seconds =" & @TAB & @TAB & $s_secs) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
kurtkafka Posted May 25, 2009 Share Posted May 25, 2009 (edited) Thanks a lot for the quick answer. Now I see, where the problem was. StringRegExp is returning an array. Stupid me. :-) Edited May 25, 2009 by kurtkafka Link to comment Share on other sites More sharing options...
kurtkafka Posted May 27, 2009 Share Posted May 27, 2009 I'm slowly moving forward concerning StringRegExp. I downloaded and used the tool from Szhlopp to play a bit around and get used to the synthax. (Great tool Szhlopp!) http://www.autoitscript.com/forum/index.ph...pression+tester In this tool I downloaded a website as text (http://www.playforyourclub.com/shouts1.php) built a Synthax ([\x20-\x7E]{3})(?:[ ])([A-Za-z0-9 ]*)([0-9]{6}?)([A-Za-z0-9 ]*)([0-9]{2}:[0-9]{2})(?:.)([0-9]{2}/[0-9]{2}/[0-9]{4}) and the tool is returning exactly what I want. Something like this: [0] = mjb [1] = Hearts 78 [2] = 350108 [3] = in a row [4] = 16:08 [5] = 27/05/2009 [6] = *L* [7] = Moenchengladbach [8] = 110400 [9] = erst am abend ist [10] = 16:07 [11] = 27/05/2009 ... ...Now I tried to do it in my own script and the result for $ausschneiden is always empty. I tried to find the mistake I made for roughly 3 hours but couldn't find it. Any advice from you guys? expandcollapse popup#include <INet.au3> #include <GUIconstants.au3> #include <IE.au3> AutoItSetOption("MustDeclareVars",1) Global $text_webpage = "" Global $adresse_shouts = "http://www.playforyourclub.com/shouts1.php" Global $muster = "([\x20-\x7E]{3})(?:[ ])([A-Za-z0-9 ]*)([0-9]{6}?)([A-Za-z0-9 ]*)([0-9]{2}:[0-9]{2})(?:.)([0-9]{2}/[0-9]{2}/[0-9]{4})" Global $Editbox Global $oIE Global $ausschneiden GUICreate("Shouts", 800, 700, 100, 100) ;WinSetOnTop("Shouts", "", 1) $Editbox = GUICtrlCreateEdit ("Shouts", 10, 10, 780, 680) GUISetState() _Main() Func _Main() _shouts_laden() GUICtrlSetData($Editbox, $text_webpage) sleep(1000) _zurechtschneiden() EndFunc Func _shouts_laden(); Laden der Shoutseite , copied from Szhlopp _IELoadWaitTimeout(20000) GUICtrlSetData($Editbox, "Bitte warten...") $oIE = _IECreate($adresse_shouts, 0, 0); 0=nicht anhängen, 0=unsichtbares IE-Fenster If @error = 6 Then GUICtrlSetData($Editbox, "Zeitüberschreitung") Else GUICtrlSetData($Editbox, _IEBodyReadText($oIE)) $text_webpage = _IEBodyReadText($oIE) EndIf _IEQuit($oIE) EndFunc ;==>_F10_time_stotty Func _zurechtschneiden() $ausschneiden = StringRegExp($text_webpage, $muster , 3) MsgBox(0,"",$ausschneiden) EndFunc Link to comment Share on other sites More sharing options...
GEOSoft Posted May 27, 2009 Share Posted May 27, 2009 $ausschneiden is a 0 based array , not a string. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Xenobiologist Posted May 27, 2009 Share Posted May 27, 2009 Hi, there is also a good German forum (www.autoit.de), maybe this makes it easier some time. Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
kurtkafka Posted May 27, 2009 Share Posted May 27, 2009 (edited) $ausschneiden is a 0 based array , not a string.That did the trick. Sorry for the hassle. Edit: And thank you, of course.@Xenobiologist: Thank you for the tip. Edited May 27, 2009 by kurtkafka Link to comment Share on other sites More sharing options...
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