Jump to content

get Z between X and Y from a string


tom13
 Share

Recommended Posts

Sigh... I wrote tons of text in this thread and it somehow all got deleted after I pressed submit.. probably some forum bug when there is too much text?

Okay.. I'll make it short this time.

I want to get a string from a string with _StringBetween

The string looks like this: "<divclass="health-stat"><h4>Health:</h4><p><span>12065</span></p></div>"

So I coded this:

#include <INet.au3>
#include <String.au3>

$url = "http://eu.wowarmory.com/character-sheet.xml?r=Stormscale&n=Sodar"
$rawsource = _INetGetSource ($url)
$source = StringStripWS($rawsource, 8)

$health_start = "<h4>Health:</h4><p><span>"
$health_end = "</span></p>"
$health = _StringBetween ( $source, $health_start, $health_end)

MsgBox(4096, "Test", $health, 10)

But when I execute it it gives me an empty string as return.. anyone knows why or what I do wrong?

It should, in the example above, return "12065"

Edited by tom13
Link to comment
Share on other sites

  • Moderators

1. You need to look up "escape characters" if you are going to use the RegExp part of _StringBetween.

2. The return value is not a regular variable, it's an Array.

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

1. You need to look up "escape characters" if you are going to use the RegExp part of _StringBetween.

2. The return value is not a regular variable, it's an Array.

thanks! didn't know I had to use an array because its only found 1 time

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...