toonboon Posted December 14, 2008 Share Posted December 14, 2008 (edited) Hi,I need help with a regular expression, I have the following bits of text:Attack</a></td><tdclass="alL">252</td><tdclass="alL">99</td> Defence</a></td><tdclass="alL">144</td><tdclass="alL">99</td> And so on, for all runescape skillsAs some of you may see, these are runescape skills, I am building a runescape highscore checker.now I want to extract the lvl from each, which is the 99 in the coding. I came up with this expression, but it doesn't seem to work.Stringregexp($source, "Attack</a></td><tdclass="alL">(?: [0-9\,]{0,9})</td><tdclass="alL">(0-9{0,2})</td>")please help me out. Edited December 14, 2008 by toonboon [right]~What can I say, I'm a Simplistic person[/right] Link to comment Share on other sites More sharing options...
oMBRa Posted December 14, 2008 Share Posted December 14, 2008 what's your output should like? Link to comment Share on other sites More sharing options...
toonboon Posted December 14, 2008 Author Share Posted December 14, 2008 my output should be the 99 in this case, but can be any number from 1-99 [right]~What can I say, I'm a Simplistic person[/right] Link to comment Share on other sites More sharing options...
oMBRa Posted December 14, 2008 Share Posted December 14, 2008 #include <Array.au3> $string = 'Attack</a></td><tdclass="alL">252</td><tdclass="alL">99</td>' & _ 'Defence</a></td><tdclass="alL">144</td><tdclass="alL">99</td>' $skill = StringRegExp($string, 'alL">([0-9]{2})</td>', 3) If @error Then MsgBox(0, '', @error) EndIf _ArrayDisplay($skill) Link to comment Share on other sites More sharing options...
TinyBoy Posted December 14, 2008 Share Posted December 14, 2008 my output should be the 99 in this case, but can be any number from 1-99#include <string.au3> $s='Attack</a></td><tdclass="alL">252</td><tdclass="alL">99</td>' $a=_StringBetween($s,">","<") $result=$a[4] MsgBox(0, '',$result ) Link to comment Share on other sites More sharing options...
oMBRa Posted December 14, 2008 Share Posted December 14, 2008 #include <string.au3> $s='Attack</a></td><tdclass="alL">252</td><tdclass="alL">99</td>' $a=_StringBetween($s,">","<") $result=$a[4] MsgBox(0, '',$result ) with your code, he cant determine where is the value he is searching for in the array Link to comment Share on other sites More sharing options...
toonboon Posted December 14, 2008 Author Share Posted December 14, 2008 (edited) #include <Array.au3> $string = 'Attack</a></td><tdclass="alL">252</td><tdclass="alL">99</td>' & _ 'Defence</a></td><tdclass="alL">144</td><tdclass="alL">99</td>' $skill = StringRegExp($string, 'alL">([0-9]{2})</td>', 3) If @error Then MsgBox(0, '', @error) EndIf _ArrayDisplay($skill) Thank you very much, though it doesn't solve my problem. With this example I can't figure out the skill this belongs to. I would like to do it in one line, $attack = StringRegExp($source, "somethingsomethingsomething") $defence = StringRegExp($source, "somethingsomethingsomething") Edited December 14, 2008 by toonboon [right]~What can I say, I'm a Simplistic person[/right] Link to comment Share on other sites More sharing options...
oMBRa Posted December 14, 2008 Share Posted December 14, 2008 so the output should be: ''Attack:99'' ''Defence:99'' ? Link to comment Share on other sites More sharing options...
toonboon Posted December 14, 2008 Author Share Posted December 14, 2008 no the variable $attack should read 99, but only if the Attack is present.. [right]~What can I say, I'm a Simplistic person[/right] Link to comment Share on other sites More sharing options...
oMBRa Posted December 14, 2008 Share Posted December 14, 2008 (edited) #include <Array.au3> Global $String = 'Attack</a></td><tdclass="alL">252</td><tdclass="alL">99</td>' & _ 'Defence</a></td><tdclass="alL">144</td><tdclass="alL">98</td>' Global $Skills $Attack = StringRegExp($string, '(?i)(Attack|Defence).{0,50}([0-9]{2})</(?i)td>', 3) If @error Then MsgBox(0, '', @error) EndIf _ArrayDisplay($Attack) Edited December 15, 2008 by oMBra Link to comment Share on other sites More sharing options...
TinyBoy Posted December 14, 2008 Share Posted December 14, 2008 #include <string.au3> Local $Attack = "??",$Defence = "??" $p='([alpha]*)(?:<.*L">)(.*)(?:<.*)' $s='Attack</a></td><tdclass="alL">252</td><tdclass="alL">99</td>' Execute(StringRegExpReplace('assign("'&$s,$p,'\1","\2")')) $s='Defence</a></td><tdclass="alL">144</td><tdclass="alL">66</td>' Execute(StringRegExpReplace('assign("'&$s,$p,'\1","\2")')) MsgBox(0, "","Attack: "&$Attack & @CRLF &"Defence: "&$Defence ) 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