WhiteCrow Posted August 21, 2005 Share Posted August 21, 2005 (edited) This is a whole page, spaces removed.Themoreattackturnsyouuseinanattack,themoreexperienceandgoldyouwillget.Gold:991,954UntrainedCitizens:19Level:19Experience:177,669(nextlevelin9,831)TurnsAvailable:371UsernameorIDTimeUntilNextTurn9:56DarkThroneTime15:168/15- OmegaLaunch/StatusUpdateUntrainedCitizens:19GoldAvailable:991,954TypeYou HaveCostQuantityMiner2,3742,000SoldieI need to get the Gold ammount out of this texti got this code, and it does that :$klad=Clipget() $klad=StringStripWS ($klad, 8) MsgBox(0, "Dark", $klad ) $start = StringInStr($klad,"Gold:") + 5 $end = StringInStr($klad,"Untrained") $result = StringMid($klad, $start , $end - $start) MsgBox(0,"Result",$result)But i would like to put them in a array with StringregExp#include <array.au3> Dim $lost [20] $klad=Clipget() $lost=StringRegExp ($klad, "Gold:(\d)", 3) MsgBox(0, "Window", $lost[1] );this displays nothingI just cant seem to bend my mind around regular expressions, feel so stupid It seems to me that stringparsing becomes much easier with StringRegExp, if i could just figure out how to express stuff. Who can help me out ? Edited August 30, 2005 by WhiteCrow Link to comment Share on other sites More sharing options...
steve8tch Posted August 21, 2005 Share Posted August 21, 2005 Does this work for you. $x = "Themoreattackturnsyouuseinanattack,themoreexperienceandgoldyouwillget.Gold:991,954UntrainedCitizens:19Level:19Experience:177,669(nextlevelin9,831)TurnsAvailable:371UsernameorIDTimeUntilNextTurn9:56DarkThroneTime15:168/15-OmegaLaunch/StatusUpdateUntrainedCitizens:19GoldAvailable:991,954TypeYouHaveCostQuantityMiner2,3742,000Soldier(Offense)01,500Guard(Defense)01,500Spy402,500Sentry(AntiSpy)02,500Advancedunitscannotbeuntrained.AlladvancedunitsmustbetrainedfromBasicunitsinthatsameclass(soldierstoknights,sentriestosentinels...).VeteranSpiescannotbesentonspymissions.TypeYouHaveCostQuantityKnight(Offense)15610,000Archer(Defense)13910,000VeteranSpy5610,000Sentinel(AntiSpy)9710,000Copyright2004-2005LazarusSoftware[AntiSpamPolicy|PrivacyPolicy|TermsofUse|Rules]" $pattern = "(Gold:.*?Untrained)" $msg = "" $y = StringRegExp($x,$pattern,3) $error = @error If @error = 0 and @extended = 1 Then For $z = 0 to UBound($y) - 1 $msg = $msg & $y[$z] & @CRLF Next Msgbox(0,"",$msg) Else msgbox(0,"error","@error = " & $error & @CRLF & "@extended = " & @extended) EndIf [ Link to comment Share on other sites More sharing options...
WhiteCrow Posted August 22, 2005 Author Share Posted August 22, 2005 Your code works just fine This is what i made of it $x = "Themoreattackturnsyouuseinanattack,themoreexperienceandgoldyouwillget.Gold:991,954UntrainedCitizens:19Leve $pattern = "(Gold:.*?Untrained)" $msg = "" $y = StringRegExp($x,$pattern,1) $error = @error If @error = 0 and @extended = 1 Then For $z = 0 to UBound($y) - 1 $msg = $msg & $y[$z] & @CRLF Next Msgbox(0,"",$msg) Else msgbox(0,"error","@error = " & $error & @CRLF & "@extended = " & @extended) EndIf $msg=StringTrimRight($msg, 11) $msg=StringTrimLeft($msg, 5) $msg=StringReplace ($msg, ",", "") $gold=Number($msg) Msgbox(0,"gold",$gold) Thank you verry much Steve8tch, now i have the gold in integer, i can calculate some stuff with it Just what i need... Link to comment Share on other sites More sharing options...
w0uter Posted August 22, 2005 Share Posted August 22, 2005 $pattern = "(Gold:.*?Untrained)" should be $pattern = "Gold:(.*?)Untrained" so you have to do less parsing. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
WhiteCrow Posted August 24, 2005 Author Share Posted August 24, 2005 (edited) $pattern = "(Gold:.*?Untrained)"should be$pattern = "Gold:(.*?)Untrained"so you have to do less parsing.<{POST_SNAPBACK}>Thanks for thinking with me Wouter, that does work Edited August 24, 2005 by WhiteCrow 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