Jump to content

StringRegExp help..


toonboon
 Share

Recommended Posts

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 skills

As 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 by toonboon

[right]~What can I say, I'm a Simplistic person[/right]

Link to comment
Share on other sites

#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

#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

#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 by toonboon

[right]~What can I say, I'm a Simplistic person[/right]

Link to comment
Share on other sites

#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 by oMBra
Link to comment
Share on other sites

#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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...